Sarah,
It is very difficult to suggest an approach because you have not said
what the structure of your data is. It would also help to know what
version of S+ you are using. Please repost giving that info.
Dave
Thanks to David for seeking clarification, and to Clint Bowman for
suggesting a solution in perl. Apologies for my naivety, but I'm not sure
what David means by the "structure" of my data beyond it being a data frame
object in S-PLUS. I should clarify that there is no date field, per se --
there are separate fields for day, month, study day (1 through 92) and
Julian day. I am using the student version of S+ 7.0.
After posting to the list I came up with this brute-force solution, but I'm
still open to suggestions for another approach:
daily.mean <- master[master$Julian.day==1,]
daily.mean <- assign.rows(daily.mean, count.rows(daily.mean)+1,
value=apply(daily.mean, 2, mean))
for (i in 2:92){
day <- master[master$Julian.day==i,]
day <- assign.rows(day, count.rows(day)+1, value=apply(day, 2, mean))
daily.mean <- rbind.data.frame(daily.mean, day)
}
Then I went on to write functions that estimate mean values for the days
with no observations. It works, which is all that really matters, but I
suspect that there must be an easier way.
Thanks to all,
Sarah
Sarah Henderson <sarah.henderson@ubc.ca>
Sent by: s-news-owner@lists.biostat.wustl.edu
04/23/2006 07:30 PM
To
s-news@lists.biostat.wustl.edu
cc
Subject
[S] Inserting rows for OBS and NOOBS days
Hello all --
I have data spanning a 92-day period. The number of observations per
day ranges from 0 to 1000+. I need to insert a blank row for each
day after the day's last observation. If there are not observations,
I still need to insert a row for that day. Is there an elegant way
to do this?
Many thanks,
Sarah
--------------------------------------------------------------------
This message was distributed by s-news@lists.biostat.wustl.edu. To
unsubscribe send e-mail to s-news-request@lists.biostat.wustl.edu with
the BODY of the message: unsubscribe s-news
|