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.