Tomek
Tomek

Reputation: 13

Grep in List of Vectors (R)

I tried to do vector of vectors in R. Found a proposition to do List of Vectors - now it works, but not fully correctly. When I try to grep sth in any vector from list I always receive "1". How do the vector of vectors, where I can grep in each?

waluty <- list(waluty96, waluty97, waluty98, waluty99, waluty00, waluty01, waluty02, waluty03, waluty04, waluty05, waluty06, waluty07, waluty08, waluty09, waluty10, waluty11, waluty12, waluty13, waluty14, waluty15, waluty16, waluty17)
grep("DEM", (waluty[2]))

[1] 1

Upvotes: 0

Views: 2867

Answers (1)

Tim Biegeleisen
Tim Biegeleisen

Reputation: 521259

You could use lapply():

result <- lapply(waluty, function(x) grep("DEM", x))

Upvotes: 2

Related Questions