Re: [R] Entering table with multiple columns & rows

From: Jorge Ivan Velez <jorgeivanvelez_at_gmail.com>
Date: Tue, 01 Mar 2011 00:23:31 -0500

Hi Laura,

May be yo meant:

diet <- matrix(c(24,134,9,52,23,72,12,15), ncol = 2, byrow = TRUE) # note ncol = 2
rownames(diet) <- c("none", "healthy", "unhealthy", "dangerous") colnames(diet) <- c('Yes', 'No')
diet

HTH,
Jorge

On Mon, Feb 28, 2011 at 9:17 PM, Laura Clasemann <> wrote:

>
> Hi,
>
> I'm having difficulty with getting a table to show with
> multiple rows and columns. Below is the commands that I've typed in and
> errors that I am getting. Thank you.
>
> Laura
>
>
> Table trying to enter:
>
> Diet: Binger-yes: Binger-No: Total:
> None 24 134 158
> Healthy 9 52 61
> Unhealthy 23 72 95
> Dangerous 12 15 27
>
>
>
>
>
> > diet=matrix(c(24,134,9,52,23,72,12,15),ncol=4,byrow=TRUE)
> > rownames(diet)=c("none", "healthy", "unhealthy", "dangerous")
> Error in dimnames(x) <- dn :
> length of 'dimnames' [1] not equal to array extent
> > diet=matrix(c(24,134,9,52,23,72,12,15), ncol=4, byrow=4)
> > rownanes(diet)=c("none", "healthy", "unhealthy", "dangerous")
> Error in rownanes(diet) = c("none", "healthy", "unhealthy", "dangerous") :
> could not find function "rownanes<-"
> > rownames(diet)=c("none", "healthy", "unhealthy", "dangerous")
> Error in dimnames(x) <- dn :
> length of 'dimnames' [1] not equal to array extent
> > diet=matrix(c(24,134,9,52,23,72,12,15), ncol=4, byrow=4)
> > rownames(diet)=c("none", "healthy", "unhealthy", "dangerous")
> Error in dimnames(x) <- dn :
> length of 'dimnames' [1] not equal to array extent
> >
>
>
> [[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.
>

        [[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. Received on Tue 01 Mar 2011 - 06:37:17 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Tue 01 Mar 2011 - 07:40:18 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive