try this:
> x<-c(1,2,5,6)
> y<-c(5,3,6,8)
> xy<-data.frame(x,y)
> xy
  x y
1 1 5
2 2 3
3 5 6
4 6 8> new.df <- data.frame(x=seq(max(xy$x)), y=rep(0, max(xy$x)))
> new.df
  x y
1 1 0
2 2 0
3 3 0
4 4 0
5 5 0
6 6 0> new.df$y[xy$x] <- xy$y
> new.df
  x y
1 1 5
2 2 3
3 3 0
4 4 0
5 5 6
6 6 8>
On 8/20/06, zhijie zhang <epistat@gmail.com>
wrote:>
> Dear friends,
> suppose my dataset *xy* :
> x    y
> 1   5
> 2   3
> 5   6
> 6   8
> -------------generated the data------
> x<-c(1,2,5,6)
> y<-c(5,3,6,8)
> xy<-data.frame(x,y)
> ---------------------------------------
> I want to fit the gap in x with the corresponding y=0, I use the following
> programs to generate a new dataset *a*:
> ----------------------------------------
> a<-matrix(c(seq(1,6),rep(0,6)),ncol=2)
> a<-data.frame(a)
> names(a)<-c('i','x')
> ----------------------------
> > a
> i   x
> 1   0
> 2   0
> 3   0
> 4   0
> 5   0
> 6   0
> -------------------------
> *if(a$i=xy$x) a$x<-xy$y*  # hope to replace the corresponding x-values
in
> a
> with xy$y, but failed.
> Anybody can tell me how to finish the task on fill the series data?
> *My expected data should be:*
> * 1   5
> 2   3
> 3   0
> 4   0
> 5   6
> 6   8*
>
> Thanks a lot!
>
>
>
> --
> Kind Regards,
> Zhi Jie,Zhang
>
>        [[alternative HTML version deleted]]
>
> ______________________________________________
> 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.
>
-- 
Jim Holtman
Cincinnati, OH
+1 513 646 9390
What is the problem you are trying to solve?
	[[alternative HTML version deleted]]