[R] how to select all columns that contain in any of their rows a partial match for a string?
ru|pb@rr@d@@ @end|ng |rom @@po@pt
Sat Oct 5 21:24:12 CEST 2019
Try the following
cols <- sapply(tot, function(x) any(grepl("^E94", x)))
To have the column numbers,
Hope this helps,
Às 19:50 de 05/10/19, Ana Marija escreveu:
> I have a data frame tot which has many columns and many rows.
> I am trying to find all columns that have say a value in any of their
> rows that STARTS WITH: "E94"
> for example there are columns like this:
>  NA "E9420"
> I tried:
> but this didn't return me anything. Data type in those columns is character.
> R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
More information about the R-help