Re: [R] cbind and rbind

From: Andy Bunn <abunn_at_whrc.org>
Date: Tue 23 Aug 2005 - 10:33:21 EST


Like this?

 x <- cbind(rnorm(10), rnorm(10))
# add row total
 x <- cbind(x, rowSums(x))
# add col sums
 x <- rbind(x, colSums(x))

The KEY to posting to r-help is writing a small example that helpers can reproduce. When I write one, I often find the answer myself. I often don't and get eviscerated by some R-guru, but that's part of the fun of it all!

I hope that helps, Andy

> -----Original Message-----
> From: Tony Evans [mailto:tonyevans@esat.net.au]
> Sent: Monday, August 22, 2005 8:03 PM
> To: Andy Bunn
> Subject: Re: [R] cbind and rbind
>
>
> Sorry, I did read the guide but am very new to this.
>
> I have created a table and have made totals of rows and columns using
> apply() I now want to add these totals to the table.
> I have been able to add one OR the other using cbind and rbind
> but have not
> been able to find a code to add them both.
>
> I hope this is better information.
>
> Tony Evans
> Australia
>
> ----- Original Message -----
> From: "Andy Bunn" <abunn@whrc.org>
> To: " Tony Evans" <tonyevans@esat.net.au>
> Sent: Tuesday, August 23, 2005 10:02 AM
> Subject: RE: [R] cbind and rbind
>
>
> > Try reading the posting guide and give a small example of what
> you want to
> > try and do...then we can help better.
> >
> > x <- rnorm(10)
> > y <- rnorm(10)
> > z <- cbind(x,y)
> > w <- rbind(z,rnorm(2))
> >
> >
> > -Andy
> >
> >
>
>



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 Received on Tue Aug 23 10:38:15 2005

This archive was generated by hypermail 2.1.8 : Sun 23 Oct 2005 - 15:43:15 EST