[R] R: Searching and deleting elements of list
jastar
mswierniak at o2.pl
Wed Mar 14 10:00:22 CET 2007
This is exactly what I need
Thank's a lot!!
Guazzetti Stefano wrote:
>
> you could try mapply
>
> mydata2<-mapply("[", mydata, lapply(mydata, function(x) !x %in% A))
> mydata2[[1]]<-A #to replace the obviously deleted elements of "A"
> mydata2
> mydata2[[1]]
> mydata2[[2]]
> mydata2[[3]]
> mydata2[[4]]
>
> Stefano
>
>
> -----Messaggio originale-----
> Da: r-help-bounces at stat.math.ethz.ch
> [mailto:r-help-bounces at stat.math.ethz.ch]Per conto di jastar
> Inviato: giovedì 8 marzo 2007 12.31
> A: r-help at stat.math.ethz.ch
> Oggetto: [R] Searching and deleting elements of list
>
>
>
> Hi,
> I have a problem. Please, look at example and try to help me!!
>
>> A<-c("aaa","bbb","ccc","ddd","eee")
>> B<-c("vvv","ooo","aaa","eee","zzz","bbb")
>> C<-c("sss","jjj","ppp","ddd")
>> D<-c("bbb","ccc")
>>mydata=list(A,B,C,D)
>
> I want to find and delete from 'mydata' all elements which occur in A
> (except A).
> I mean after "operation":
>> mydata[[1]]
> [1] "aaa" "bbb" "ccc" "ddd" "eee"
>> mydata[[2]]
> [1] "vvv" "ooo" "zzz"
>> mydata[[3]]
> [1] "sss","jjj","ppp"
>> mydata[[4]]
> NULL
>
> My list have about 10000 subelements (each contains several strings) so
> using loops is senseless.
>
> Thank's for all replies and sorry for my English (I hope you understand
> what
> I'm talking about) :-)
>
> --
> View this message in context:
> http://www.nabble.com/Searching-and-deleting-elements-of-list-tf3368489.html#a9372270
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> 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 at stat.math.ethz.ch mailing list
> 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.
>
>
--
View this message in context: http://www.nabble.com/Searching-and-deleting-elements-of-list-tf3368489.html#a9470572
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list