[R] Entering table with multiple columns & rows

Ista Zahn izahn at psych.rochester.edu
Tue Mar 1 04:22:01 CET 2011


Hi Laura,
If you type

diet

you will see that it has 4 columns and 2 rows. Since it has only 2
rows you cannot give it rownames of length 4.

Best,
Ista

On Tue, Mar 1, 2011 at 2:17 AM, Laura Clasemann <violagirl470 at msn.com> 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.
>



-- 
Ista Zahn
Graduate student
University of Rochester
Department of Clinical and Social Psychology
http://yourpsyche.org



More information about the R-help mailing list