[R] df manipulation

2007-07-19 Thread Nikola Markov
I have multicolumn data.frames with the first comumn giving ordinal observation index ( ex.: 1 4 7 9 11 13 etc). I would like to fill up the missing observations (i.e. 2 3 5 6 8 etc) with NAs. Thank you __ R-help@stat.math.ethz.ch mailing list

Re: [R] df manipulation

2007-07-19 Thread Henrique Dallazuanna
Hi, see below: df index value 1 1 1 2 4 6 3 7 4 4 9 5 511 3 613 2 foo - function(x){ + index - ifelse(x %in% df$index, df$value[which(df$index %in% x)], NA) + return(index) + } df_ok - data.frame(index=1:13, value=sapply(1:13, foo))

Re: [R] df manipulation

2007-07-19 Thread Uwe Ligges
Nikola Markov wrote: I have multicolumn data.frames with the first comumn giving ordinal observation index ( ex.: 1 4 7 9 11 13 etc). I would like to fill up the missing observations (i.e. 2 3 5 6 8 etc) with NAs. Please specify reproducible examples, they make it much easier to help! If