Hello,

Try the following

cols <- sapply(tot, function(x) any(grepl("^E94", x)))

To have the column numbers,

which(cols)


Hope this helps,

Rui Barradas

Às 19:50 de 05/10/19, Ana Marija escreveu:
Hello,

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:

unique(tot$diagnoses_icd9_f41271_0_44)
[1] NA      "E9420"

I tried:
s=select(tot,starts_with("E94"))

but this didn't return me anything. Data type in those columns is character.

Thanks
Ana

______________________________________________
R-help@r-project.org 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.


______________________________________________
R-help@r-project.org 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.

Reply via email to