Try this: Lines <- "ID;record 1;20 ;30 ;25 2;26 ;15 3;21"
x <- read.table(textConnection(Lines), sep = ";", header = TRUE) library(zoo) x$ID <- na.locf(x$ID) On Sun, Dec 14, 2008 at 11:56 PM, Zhixin Liu <z...@efs.mq.edu.au> wrote: > Hi R helpers, > > If I have a dataset looks like: > ID record > 1 20 > . 30 > . 25 > 2 26 > . 15 > 3 21 > 4..................... > > And I want it becomes > ID record > 1 20 > 1 30 > 1 25 > 2 26 > 2 15 > 3 21 > 4..................... > > That is, I have to duplicate IDs for those with multiple records. I am > wondering it is possible to be done in R, and I am grateful if you would > like to show me the direction. > > Many thanks! > > Zhixin > > ______________________________________________ > R-help@r-project.org 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. > -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40" S 49° 16' 22" O [[alternative HTML version deleted]]
______________________________________________ R-help@r-project.org 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.