See if one of %in% or match gets your further.
> 1:10 %in% c(1,3,5,9)
[1] TRUE FALSE TRUE FALSE TRUE FALSE FALSE FALSE TRUE FALSE
> match(c(1,3,5,9), 1:10)
[1] 1 3 5 9
> match(c(1,3,5,9), 10:1)
[1] 10 8 6 2
date03 as offered was not a list, but a vector.
date04 <- date02[which(date02$date %in% date3), ] # might work,
nothing to test it on
If you only want the column of matching dates and not all the rows
that have matching dates then this might work:
date04 <- date02[which(date02$date %in% date3), "date" ]
From you incorrect use of the term "list" (in the context of R,
anyway), I am guessing that you don't really want lists but rather
subsets of data.frames. Vector and list are not interchangeable terms
in these parts.
--
David Winsemius
On Jan 14, 2009, at 2:53 PM, glenn wrote:
> Dear All;
>
> Is it possible to create a list of lists (I am sure it is) along these
> lines;
>
> I have a dataframe data02 that holds a lot of information, and the
> first
> column is ?date?
>
> I have a list of dates in;
>
> data03<-c(date1,.....,daten)
>
> And would like to create a list;
>
> data04 <- subset(data02, date == data03[1,])
>
> Ie. data04 holds the data from data02 that matches a date in data03
>
> How do I create a list data04 that instead rolls through all the
> elements of
> data03 and each element of data04 is a list
>
> Regards
>
> Glenn
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org 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.