Try this: > x <- data.frame(a=1:10, b=1:10) > x a b 1 1 1 2 2 2 3 3 3 4 4 4 5 5 5 6 6 6 7 7 7 8 8 8 9 9 9 10 10 10 > # add a row at the top > x <- x[c(1,seq(nrow(x))),] > x a b 1 1 1 1.1 1 1 2 2 2 3 3 3 4 4 4 5 5 5 6 6 6 7 7 7 8 8 8 9 9 9 10 10 10 > > # fill in with the values you want. > x[1,] <- NA
On Mon, May 17, 2010 at 11:28 AM, <ecvet...@uwaterloo.ca> wrote: > I have a large data frame 48:2185 with different numbers. > I would like to add only one row at the very top of my data frame with 0's > or NA's. > I don't know which approach to use. Should i create 2 different data frames > and merge them? Ive also tried the rbind command with no luck. I would > appreciate some help to achieve what I'm trying to create. > Thanks! > > ______________________________________________ > 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<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 that you are trying to solve? [[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.