Re: [R] update index in

From: Mark Lyman <mark.lyman_at_gmail.com>
Date: Wed 25 Oct 2006 - 19:15:58 GMT

Kim Milferstedt <milferst <at> uiuc.edu> writes:

>
> Hello,
>
> I have a time series of data as a data.frame. Occasionally there is
> one or more days missing (e.g. data available for days 2, 3, 4, 8, 9,
> 10 --> missing days between 4 and 8). The experimental time
> information can be found in the 2nd column of "data". I would like to
> have a continuous time line with one time point per day. Therefore I
> try to insert lines for the missing days that contain zeros for the
> data categories just to fill the columns.
>
<SNIP>
>
> Thanks already,
>
> Kim
>
<SNIP>

I believe this will also do what you want:

> days<-c(1:10)[-5:-7]
> xx<-rnorm(7)
> data<-data.frame(xx,days)
> new.data<-merge(data,data.frame(days=1:10),all.y=TRUE)

It usually is not a good idea to use zeroes as placeholders for missing values.

Mark Lyman



R-help@stat.math.ethz.ch 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. Received on Thu Oct 26 05:19:22 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Wed 25 Oct 2006 - 19:30:16 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.