I have colnames which need " " because they have spaces,
however trying to calculate
rowSums(myTibble[ , c("var name1" : "var name11")], na.rm = FALSE)
results in error: Error in "var name1" : "var name11" : NA/NaN argument
I want to use names, not colnumbers, and tried with " " and quotes on tilde key but to no success. What is wrong?
PS
I found a workaround (rowSums(myTibble[,c(match("var name1", colnames(myTibble)) : match("var name11", colnames(myTibble)))], na.rm = FALSE) but it is not neat / looks ugly
P.S. Is there a quick method to calculate row sums across several columns with R pipe operator?
I mean selecting columns with select("col1":"col3") |> mutate(sum = ....).
I am at a loss how to do it (trying with rowSums() )
I did not use c_across(), thinking rowwise() will be enough to tell sum() to calculate sums for rows
(I had tried sum() before rowSums() but it did not work properly ).