Hadley, Sunil, and list,
This is not quite doing what I wanted it to do (as far as I can tell). I
perhaps did not explain it thoroughly. It seems to be sampling one value
for each day leaving ~200 observations. I need for it randomly chose one hab
value for each bird if there is more than one
On Thu, Jul 2, 2009 at 8:15 AM, James Martinjust.strut...@gmail.com wrote:
Hadley, Sunil, and list,
This is not quite doing what I wanted it to do (as far as I can tell). I
perhaps did not explain it thoroughly. It seems to be sampling one value
for each day leaving ~200 observations. I need
ddply(df, c(date, id), function(df) df[sample(nrow(df), 1), ])
Thanks to Hadley and Sunil. The above code solves my problem.
jm
On Mon, Jun 29, 2009 at 9:11 AM, James Martin just.strut...@gmail.comwrote:
All,
I have data that looks like below. For each id there may be more than one
value
#Highlight the text below (without the header)
# read the data in from clipboard
df - do.call(data.frame, scan(clipboard, what=list(id=0,
date=,loctype=0 ,haptype=0)))
# split the data by date, sample 1 observation from each split, and rbind
sampled_df - do.call(rbind, lapply(split(df,
On Wed, Jul 1, 2009 at 2:10 PM, Sunil
Suchindransunilsuchind...@gmail.com wrote:
#Highlight the text below (without the header)
# read the data in from clipboard
df - do.call(data.frame, scan(clipboard, what=list(id=0,
date=,loctype=0 ,haptype=0)))
# split the data by date, sample 1
All,
I have data that looks like below. For each id there may be more than one
value per day. I want to select a random value for that day for that id.
The end result would hopefully be a matrix with the id as rows, date as
columns and populated by the random hab value. Thanks to someone on
6 matches
Mail list logo