Dear S-plus user,
Thanks for your attention to my request. I received three reply. Prof
Frank advice gave the solution to my request. Stated below are the three
response given. My comment on the proposed command is also stated:
#Example 1 by Prof. Frank E Harrel Jr
tapply(var3, list(var1,var2), function(y) sum(!is.na(y)))
My comment: The command produce tables excluding "NA's"
#Example 2 by Prof. Peter Alspach
temp
[,1] [,2] [,3]
[1,] 1 6 1
[2,] 2 6 2
[3,] 3 6 3
[4,] 4 6 4
[5,] 1 6 5
[6,] 2 7 6
[7,] 3 8 7
[8,] 4 8 8
[9,] 1 8 9
[10,] 2 8 10
[11,] 3 8 11
[12,] 4 9 12
[13,] 1 9 13
[14,] 2 9 14
[15,] 3 9 15
[16,] 4 9 16
> tapply(temp[,3], list(temp[,1], temp[,2]), length)
6 7 8 9
1 2 NA 1 1
2 1 1 1 1
3 1 NA 2 1
4 1 NA 1 2
My comments: The commands produce table which include "NA's".
Example 3 Prof. James Stapleton
use "table"
My comments: Although this suggestion does'nt solve my problems, I've
learnt new command using table
Thanks.
Abd Rahman
---------- Forwarded message ----------
Date: Thu, 29 Apr 1999 08:29:20 +0000 (GMT)
From: Abdul Rahman Kassim <rahmank@frim.gov.my>
To: s-news@wubios.wustl.edu
Subject: [S] Summarize data into table
Dear S-plus user,
I am new to S-plus and would appreciate any assistance. I am using S-plus
4.5 Release 2.
I have a large data sets (7000 records) with 5 variables (2 categories
and 3 continous). I am interested to summarized the data set into a table with
variable 1 (categorical) as rows and variable 2 (categorical) as columns
and the cell contain the number of individual for variable 3 (continous).
I have tried using "aggregate" (as described in pg 74 Programmers Guide), but
thats only summarized the data by rows. For each column I have to write
each category of variable 2. This seemed to be impractical because I have
about 200 category.
Thanks in advanced for any asistance.
Abd Rahman Kassim
Silviculturist,
Natural Forest Division
Forest Research Institute Malaysia
Kepong 52109
Kuala Lumpur
MALAYSIA
-----------------------------------------------------------------------
This message was distributed by s-news@wubios.wustl.edu. To unsubscribe
send e-mail to s-news-request@wubios.wustl.edu with the BODY of the
message: unsubscribe s-news
-----------------------------------------------------------------------
This message was distributed by s-news@wubios.wustl.edu. To unsubscribe
send e-mail to s-news-request@wubios.wustl.edu with the BODY of the
message: unsubscribe s-news
|