[R] correct syntax

Marc Schwartz (via MN) mschwartz at mn.rr.com
Wed Sep 28 23:16:41 CEST 2005


On Thu, 2005-09-29 at 06:57 +1000, Stephen Choularton wrote:
> Hi 
>  
> I am trying to produce a little table like this:
>  
> 0                     1
> 0          601       408
> 1          290       2655
>  
> but I cannot get the syntax right.  
>  
> Can anyone help.
>  
> Stephen


Do you have the raw data or only the tabulated counts?

If you have the raw data, see ?table for ways to create n-dimensional
tables.

If you only have the tabulated counts, then you can use matrix():

> mat <- matrix(c(601, 290, 408, 2655), ncol = 2)
> dimnames(mat) <- list(c(0, 1), c(0, 1))

> mat
    0    1
0 601  408
1 290 2655


See ?matrix for more information.

HTH,

Marc Schwartz




More information about the R-help mailing list