I have a list of 11 dataframe and I want to apply a function that uses rowsums to create another column of sums for each row based on the specific criteria of matching a string in each of the 11 dataframe.
I have tried to use select(contains())
. I am not looking at using mutate
if possible then please show the error in the code below.
myfiles3 <- lapply(myfiles2, function(x) {x$CHINA2 <- rowSums(x[select(x, contains("China"))], na.rm = T); x})
It gives the error as Error in
[.default(x, select(x, contains("China"))) :
invalid subscript type 'list'
.