Re: [R] correct syntax

From: Marc Schwartz (via MN) <mschwartz_at_mn.rr.com>
Date: Thu 29 Sep 2005 - 07:16:41 EST

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



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 Thu Sep 29 07:24:51 2005

This archive was generated by hypermail 2.1.8 : Sun 23 Oct 2005 - 17:52:56 EST