[R] fit the series data

From: zhijie zhang <epistat_at_gmail.com>
Date: Mon 21 Aug 2006 - 00:13:45 EST


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.
Received on Mon Aug 21 00:22:19 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 Mon 21 Aug 2006 - 04:21:18 EST.

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