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@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]]

