[R] need help for t.test using "by"

David Winsemius dwinsemius at comcast.net
Wed Aug 19 16:42:19 CEST 2009


On Aug 19, 2009, at 9:00 AM, 1Rnwb wrote:

>
> any one

I looked at your posting yesterday and could not figure out what your  
statistical question was, nor could I figure out how the t.test  
formula related to the column names in the data.frame. I saw no Group  
or IL1Ra variables in your data. I also tried to import that data and  
found that you had more column headers than columns. I gave up.

-- 
DW

>
> 1Rnwb wrote:
>>
>> I am trying to do ttest for each plate which has equal number of  
>> disease
>> and controls. by searching this forum I found one posting  
>> suggesting OP to
>> use "by(eo,PlateID, function(.sub) t.test(IL1Ra~Group,data=.sub))".  
>> when i
>> modified this for my use I used to get the pvalues for each plate,
>> recently upgraded to R2.9.x and now i am getting following error  
>> when i
>> use this
>>> by(eo,PlateID, function(.sub) t.test(IL1Ra~Group,data=.sub))
>> Error in t.test.formula(IL1Ra ~ Group, data = .sub) :
>>  grouping factor must have exactly 2 levels
>>
>> I checked my data file and the plate ID has "P16-P47" and the disease
>> column is "Y/N". I have search all but could not locate the answer.  
>> Can
>> anyone suggest me the direction where i am going wrong.
>> for more detail i amm posting a part of my data.
>>
>> SampleID	PlateID	Sex	Disease	Duration	Age	prt1	prt2	prt3	prt4
>> 1	P16	F	N		25.33282811	836.08979	20.04582692	295.74	11731.43
>> 2	P16	F	N		32.74912883	243.0652116	53.16487056	383.63	4451.36
>> 3	P16	M	N		3.49961999	181.5587298	23.24604762	522.52	325.52
>> 4	P16	M	N		5.249771666	261.0978097	19.69024684	833.61	2229.04
>> 5	P16	M	N		39.16612385	237.334794	83.97284692	694.03	1204.36
>> 6	P16	F	N		33.49929145	540.486536	29.69569346	895.36	72105.75
>> 7	P16	F	N		3.915997361	5215.378446	35.44324704	1023.63	101680.69
>> 8	P16	F	N		33.49929145	466.5188732	12.93422535	814.26	7169.61
>> 9	P16	F	N		38.1661348	706.5117791	19.69024684	331.62	7296.72
>> 10	P16	M	N		0.916030215	242.3011559	36.40117263	90.1	35962.08
>> 11	P16	F	Y	14975.25	42.08281552	133.8052501	29.0570764	260.55	1280.29
>> 12	P16	M	Y	1095.75	40.41593932	247.6495456	19.69024684	161.64	6685.6
>> 13	P16	F	Y	2922	25.08300169	231.6043765	9.022844487	902.53	37571.39
>> 14	P16	F	Y	12053.25	37.49924765	158.6370595	24.90606549	1.63	471.15
>> 15	P16	F	Y	14610	76.58209602	278.3837309	41.51010914	152.13	16285.49
>> 16	P16	F	Y	3287.25	49.58239171	128.4568603	17.91234645	274.99	 
>> 41823.21
>> 17	P17	M	N		2.333079994	397.4440508	55.20987654	366.37	90011.27
>> 18	P17	F	N		4.749435461	222.0839813	73.62489675	271.65	903.89
>> 19	P17	F	N		1.749468315	676.8904636	47.7037037	721.19	663.15
>> 20	P17	M	N		33.24946503	413.712486	27.42386831	611.64	4195.86
>> 21	P17	F	N		15.4162131	346.9913086	30.71604938	302.29	2151.47
>> 22	P17	F	N		33.3327405	2598.071161	107.8088094	1800.44	102005.12
>> 23	P17	M	N		9.832656179	3296.535581	54.1563786	2642.73	676.78
>> 24	P17	F	N		3.749446413	488.2589867	15.29151952	562.88	11619.62
>> 25	P17	M	N		9.749380705	159.1536586	23.41690259	132.64	931.14
>> 26	P17	M	Y	12053.25	50.91548265	173.7764722	18.90280088	52.25	 
>> 15962.05
>> 27	P17	M	Y	3652.5	25.83248096	264.8254141	35.32510288	497.33	15504.95
>> 28	P17	F	Y		28.41607073	415.3599225	35.0617284	1600.67	14224.39
>> 29	P17	F	Y	6209.25	60.74882219	213.7280879	44.41152263	111.36	9018.48
>> 30	P17	M	Y	4748.25	47.33258719	264.0016959	31.24279835	366.81	3809.83
>> 31	P17	M	Y	16071	54.49906148	112.4128794	34.40329218	114.56	1727.02
>> 32	P17	M	Y	7670.25	52.33253243	145.5753317	32.2962963	44.92	15264.84
>> 33	P17	M	Y	8766	31.74913978	220.2561296	34.40329218	130.31	2377.36
>> 34	P17	F	Y	8400.75	40.83231669	194.6662059	48.09876543	407.83	 
>> 19587.61
>> 35	P17	M	Y	12053.25	36.1661567	212.1613578	96.51775947	621.42	3269.9
>> 36	P17	M	Y	8035.5	57.91540599	115.2852178	24.79012346	282.88	8960.27
>> 37	P17	M	Y	5478.75	36.33270765	160.4592669	40.72427984	102.32	5006.77
>> 38	P17	F	Y	9496.5	34.74910692	329.8991551	40.32921811	417.32	 
>> 248857.58
>> 39	P18	F	N		14.2496731	538.5430144	54.34303351	396	4432.94
>> 40	P18	M	N		11.83263428	236.8218238	48.37595532	148.94	1414.11
>> 41	P18	M	N		7.582851659	322.2342976	87.83185053	280.84	16294.98
>> 42	P18	F	N		8.83266713	288.4507237	30.47472075	256.38	348.03
>> 43	P18	M	N		43.58245741	297.1312253	3.276042927	368.22	3627.89
>> 44	P18	F	N		45.49916004	297.1312253	160.4104035	635.12	1325.33
>> 45	P18	M	N		10.83264523	179.2726374	39.85155791	64.24	763.59
>> 46	P18	M	N		18.5827312	3389.23762	71.66394523	1105.37	45291.49
>> 47	P18	F	N		7.416300711	1345.377837	29.62228101	1195.82	19241.32
>> 48	P18	M	Y	4383	19.16634287	137.1490061	20.22826506	157.45	4026.95
>> 49	P18	M	Y	4748.25	19.0830674	226.7358839	93.61453199	507.45	1274.6
>> 50	P18	M	Y	4748.25	19.0830674	285.870034	60.87840486	330.91	586.98
>> 51	P18	M	Y	3652.5	12.33297048	195.6870101	39.56741133	48.1	16561.4
>> 52	P18	F	Y	4017.75	11.24970596	145.4550742	42.55095042	20.56	732.42
>> 53	P18	F	Y	1461	3.999956195	385.813107	63.1515775	204.62	2347.46
>> 54	P18	M	Y	4748.25	16.08310025	117.965944	58.03693906	78.33	2709.32
>> 55	P18	M	Y	1826.25	13.99984668	175.9106574	67.41377621	65.53	2069.11
>> 56	P18	M	Y	730.5	14.9158769	89.68575957	27.91740153	22.62	389.59
>> 57	P18	F	Y	6209.25	17.4161912	191.9295031	32.60582011	127.63	20291.34
>> 58	P18	F	Y	365.25	5.249771666	121.723451	61.7308446	49.39	11463.27
>> 59	P18	F	Y	4748.25	18.33290477	179.0748739	53.20644719	46.16	 
>> 111361.43
>> 60	P18	M	Y	1826.25	6.083209766	330.6801911	27.06496179	489.04	 
>> 12258.96
>> 61	P18	F	Y	3287.25	17.58274215	182.8323809	29.48020772	115.1	15324.67
>> 62	P18	F	Y	3652.5	44.16606909	248.4898719	87.24178099	139.33	16443.86
>> 63	P19	M	N		37.99958385	2197.263844	86.43305867	1492.06	3547.88
>> 64	P19	F	N		37.58252312	4588.403833	152.9115464	1722.46	9243.22
>> 65	P19	F	N		34.91565787	316.0623502	17.19804354	1582.79	12217.62
>> 66	P19	F	N		42.74901931	213.1054131	32.99689553	212.94	2714.66
>> 67	P19	F	N		10.08316596	4715.658374	50.91906722	1543.61	2490.68
>> 68	P19	F	N		43.33263099	2.258320699	0.524578302	561.12	5985.07
>> 69	P19	F	Y	365.25	8.999901438	208.5132426	32.8293986	45.72	2051.68
>> 70	P19	M	Y	4748.25	12.83262333	0	0	192.51	1255.58
>> 71	P19	M	Y	1461	16.83257952	218.2716049	65.82629413	255.01	4486.39
>> 72	P19	M	Y	5844	17.4161912	102.60631	27.80449065	49.77	622.01
>> 73	P19	M	Y	4748.25	18.33290477	182.9692941	9.965221488	159.66	2392.13
>> 74	P19	F	Y	730.5	17.24964025	100.8842461	27.97198758	157.25	176209.9
>> 75	P19	M	Y	4383	16.41620215	0.098187856	0	171.67	65286.23
>> 76	P19	M	Y	1461	6.16648524	962.1232959	112.1204345	81.67	870.82
>>
>>
>>
>>
>
> -- 
> View this message in context: http://www.nabble.com/need-help-for-t.test-using-%22by%22-tp25035006p25043601.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> 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.

David Winsemius, MD
Heritage Laboratories
West Hartford, CT




More information about the R-help mailing list