I have a vector of strings
rownames
[1] "multifarmacias descuento" "multifarmacias" "multifarmacias"
My goal is to subset rownames in one line by strings that only contain one word- the output would be
[1] "multifarmacias" "multifarmacias"
I have tried the following but it throws an error:
rownames[which(sapply(strsplit(rownames, " "),length)) == 1]
Error in which(sapply(strsplit(rownames, " "), length)) :
argument to 'which' is not logical
Is there an elegant solution to subsetting a string vector by length of words the string?