[R] add a row...

Christoph Heibl christoph.heibl at gmx.net
Fri Sep 14 16:30:08 CEST 2007


Use rbind:

d <- c(14,21)
b <- rbind(d, b)

CH



On 14.09.2007, at 16:15, Alfredo Alessandrini wrote:

> Hi,
>
> If I've a dataframe like this:
>
> a <- data.frame(a=c(14,21,14,4), b=c(21,45,23,11))
>
> print(a)
>
>    a  b
> 1 14 21
> 2 21 45
> 3 14 23
> 4  4 11
>
> I can delete the first row with:
>
> b = a[-(1),]
>
> print (b)
>
>    a  b
> 2 21 45
> 3 14 23
> 4  4 11
>
> Now, can I add to dataframe b the row that I've deleded?
>
> print (b)
>
>    a  b
> 1 14 21
> 2 21 45
> 3 14 23
> 4  4 11
>
>
>
> Best Wishes,
>
> Alfredo
>
> 	[[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at 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.



More information about the R-help mailing list