On Nov 25, 2009, at 9:44 AM, John Lipkins 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?
I think the function you will need include:
?as.Date #to get the date field into sortable form
?order #as in treedat2 <- treedat[ order(treedat$dt, treedat$Tree), ]
?duplicated # as in treedat2[ !duplicated(treedat2(Tree), ]
--
David Winsemius, MD
Heritage Laboratories
West Hartford, CT
______________________________________________
R-help@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.