shouldn't the first observation for Tree1 be " Tree1 leaves
01-01-2009"?
> x <- read.table(textConnection("Tree disease date
+ Tree1 leaves 01-01-2009
+ Tree2 roots 13-09-2009
+ Tree1 roots 24-10-2009"), header=TRUE)> closeAllConnections()
> # split by "Tree" and take first observation
> do.call('rbind', lapply(split(x, x$Tree), function(.tr) .tr[1,]))
Tree disease date
Tree1 Tree1 leaves 01-01-2009
Tree2 Tree2 roots 13-09-2009>
On Wed, Nov 25, 2009 at 9:44 AM, John Lipkins
<john.lipkins at googlemail.com> wrote:> Hey R list,
>
> A beginners question. How can I do the following:
>
> In my research population it is possible that several items can appear
> several times, measured on different moments in time. This is being
supplied
> in a total list with all observations identified by a number (per item) and
> a moment of observation (date). Now I want to make a unique list of this
> observation preserving the characteristics of the first observation. As
> example:
>
> ?Tree ?disease ?date
> ?Tree1 ?leaves ?01-01-2009
> ?Tree2 ?roots ?13-09-2009
> ?Tree1 ?roots ?24-10-2009
>
> Now I want to create a list of unique elements (in the example only once
> Tree1 and Tree2) with the first observed disease and date. For the example
> the result would look like:
>
> ?Tree ?disease ?date
> ?Tree1 ?roots ?24-10-2008
> ?Tree2 ?roots ?13-09-2009
>
> Can someone help me with this question?
>
> Thanks in advance.
> Kind regards,
>
> John
>
> ? ? ? ?[[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.
>
--
Jim Holtman
Cincinnati, OH
+1 513 646 9390
What is the problem that you are trying to solve?