Hi, it might be trivial but is there any way to get the logical vector of the
indices of a string in a vector? I thought that %in% would do but it doesn't. I
also want to filter the empty fields.
Here I want to extract the non-empty elements containing "Yes":x =c("Yes, fsd",
"", "No","","Yes, fjsdlf", "")
x[c("Yes") %in% x & x != ""]character(0)
Above, I wanted to do the 2 following operations in 1. Here with grep, it
works but %in% in above doesn't:y = x[grep("Yes", x)]
> y = y[y != ""]
> y
[1] "Yes, fsd" "Yes, fjsdlf"
Thanks
Carol
[[alternative HTML version deleted]]
______________________________________________
[email protected] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.