I have a dataset:
df <- structure(list(gender = structure(c(4L, 2L, 1L), levels = c("Boy",
"Girl", "Not listed", "Prefer not to say"), label = "The term I most closely identify with is", class = "factor"),
int_programming = c(FALSE, FALSE, FALSE), int_digmedia = c(TRUE,
FALSE, FALSE), int_spreadsheets = c(TRUE, TRUE, TRUE)), row.names = c(NA,
-3L), class = c("tbl_df", "tbl", "data.frame"))
I want to make a summary column that for each row adds the columns starting with "int_" together. I've tried:
df %>%
rowwise() %>%
mutate(any_entries = sum(starts_with("int_")))
But it gives:
`starts_with()` must be used within a *selecting* function.
How can I go about programmatically selecting columns to add together? I have a lot more columns than the test dataset provided here.