[R] Data transformation for chi-square test.
Charlie Chi
tsang0323 at hotmail.com
Tue Jun 12 09:45:52 CEST 2007
Dear all R users
:
I am a IT student with few statistical background and new R user for only
have two month exprience. I have a data named medcost, import by
read.table() as follow for example (real dataset has 500 cases), the
heander id means case id, member means members in a family and cost is the
family pay for medical cost every 6 months.
id member cost
1 4 320
2 2 150
3 3 420
4 5 330
5 6 540
6 2 310
7 4 169
8 6 647
9 3 347
10 4 567
I would like to use this dataset with chi-sqare analysis to see if there is
any realationship between family member and medical cost (more members in a
family will rise their medical cost?) I have found the pacage called stats,
but I think need to transform the dataset into a contingency table as I
read from books. I am not sure if I correct, I think the table should looks
like:
member
cost [2] [3] [4] [5] [6] Total
[0,100] 1 0 0 0 0 1
[100,200] 0 0 1 0 0 1
[200,300] 0 0 0 0 0 0
[300,400] 1 1 1 1 0 4
[400,500] 0 1 0 0 0 1
[500,600] 0 0 1 0 1 2
[600,700] 0 0 0 0 1 1
Total 2 2 3 1 2 10
I did try to use the method in chapter 5.0 of "R Introduction" to create
freqency table, but it did not work. I am wondering if any one can help me
with it? Thank you for your help.
Regards
Charlie
.
More information about the R-help
mailing list