Skip to content
Prev 388018 / 398502 Next

Finding strings in a dataset

Hello,

You can also create an extra column with the column names corresponding 
to the column col. I believe this extra column is not needed and with a 
big data set it's even a waste of time and memory space but the code 
below creates it.


res <- which(found, arr.ind = TRUE)
res <- as.data.frame(res)
res$col_name <- names(df1)[ res$col ]


With a big data set the first res is a numeric matrix and it's access 
and extraction is faster, matrix operations are generally faster than 
data.frame operations.

Hope this helps,

Rui Barradas

?s 08:30 de 16/05/21, Rui Barradas escreveu: