In case_when
all values which do not pass one of the given conditions will be set to an NA
in the new column.
I would like to keep them as they are, if the other conditions are FLASE.
In this former post I found the tip to set the last statement to:
as.numeric(as.character(p.value))
but it doesn´t work in my code below:
rsquared <- stroke_angel_data_grouped %>%
select(ly_rd4iss, ly_nihssbauf) %>%
na.omit() %>%
do(glance(lm(ly_nihssbauf ~ ly_rd4iss, data = .))) %>%
select(r.squared, p.value) %>%
# assign a text to p values in a new row for better readability in the table
mutate(p.values.text = case_when(p.value <= 0.001 ~ "P < 0.001",
p.value <= 0.01 ~ "P < 0.01",
p.value <= 0.05 ~ "P < 0.05",
TRUE ~ as.numeric(as.character(p.value)))) %>%
ungroup()
does anyone notice my mistake?