La Umut
La Umut

Reputation: 13

Filter list in R

I have a problem, I have this output in R:

[[155]]
[1] "@ju_kleeschulte" "@c"             

[[156]]
[1] "@FDPFraktionNRW" "@c_lindner"     

[[157]]
[1] "@HenningWerle" "@c_lindner"    "@RTLWEST"     

[[158]]
[1] "@Stefanswelt" "@fdp"     

But I want to filter out the complete Values (156 & 157) with "@c_lindner" in it, because it is a retweet and I would like the tweets solely without that nametag in it. So, I would like the list to be with the values 155 & 158 for example. It should look like this:

  [[155]]
[1] "@ju_kleeschulte" "@c"             

 [[156]]
[1] "@Stefanswelt" "@fdp"     

Upvotes: 1

Views: 424

Answers (1)

akrun
akrun

Reputation: 887028

We can place all the list objects in a list and then do the Filter

lapply(lstN, function(y) Filter(function(x) !any(x == "@c_lindner"), y))

data

lstN <- mget(paste0("lst", 1:10))

Upvotes: 1

Related Questions