[R] save results in a loop

Wenlan Tian tianwenlan at gmail.com
Wed Aug 13 21:43:31 CEST 2014


Hi, i'm new to R. I have a question about how to save results in a loop to
a file. Here is an example:

for (i in 6:n){
Tukey1 = HSD.test(lm(sdata_mg[,n] ~
sdata_mg$Medium+sdata_mg$color+sdata_mg$type+sdata_mg$Micro),
'sdata_mg$Micro')
}


I don't know how to do it with the loop for all data, so i just tried one
of them,
Tukey1 = HSD.test(lm(sdata_mg[,1] ~
sdata_mg$Medium+sdata_mg$color+sdata_mg$type+sdata_mg$Micro),
'sdata_mg$Micro')
Tukey1

The results look like this:

$statistics
      Mean       CV   MSerror       HSD r.harmonic
  11.87421 3.102479 0.1357148 0.5288771   7.384615

$parameters
  Df ntr StudentizedRange
  24   4         3.901262

$means
       sdata_mg[, 6]       std  r      Min      Max
111d                  11.86369 0.5317421  6 11.08623 12.45651
125d                  11.74433 0.1663130  6 11.53504 12.02412
14d                   11.54073 0.3877921  8 10.80300 11.96797
Ground                12.16673 0.3391952 12 11.56278 12.86199

$comparison
NULL

$groups
     trt    means  M
1 Ground 12.16673  a
2 111d   11.86369 ab
3 125d   11.74433 ab
4 14d    11.54073  b


How could i get all the results in the loop?

	[[alternative HTML version deleted]]



More information about the R-help mailing list