[R] Anova split by factors

ONKELINX, Thierry Thierry.ONKELINX at inbo.be
Mon Nov 18 13:33:20 CET 2013


Dear Catalin,

Have a look at the plyr package.

library(plyr)
dlply(
        eg,
        .(Exp),
        function(x) {
                aov(masa.uscat.tr~Clona,data=x)
        }
)

Best regards,

ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Research Institute for Nature and Forest
team Biometrie & Kwaliteitszorg / team Biometrics & Quality Assurance
Kliniekstraat 25
1070 Anderlecht
Belgium
+ 32 2 525 02 51
+ 32 54 43 61 85
Thierry.Onkelinx op inbo.be
www.inbo.be

To call in the statistician after the experiment is done may be no more than asking him to perform a post-mortem examination: he may be able to say what the experiment died of.
~ Sir Ronald Aylmer Fisher

The plural of anecdote is not data.
~ Roger Brinner

The combination of some data and an aching desire for an answer does not ensure that a reasonable answer can be extracted from a given body of data.
~ John Tukey


-----Oorspronkelijk bericht-----
Van: r-help-bounces op r-project.org [mailto:r-help-bounces op r-project.org] Namens catalin roibu
Verzonden: maandag 18 november 2013 13:24
Aan: r-help op r-project.org
Onderwerp: [R] Anova split by factors

Hello R-users,
I have a problem with Anova in R and I don't know how to solve that. I want to compute Anova for each experiment (exp). I try this code:

test<-lapply(split(eg,eg$Exp),function(x) aov(masa.uscat.tr ~ Clona,data =
x))
or
test<-by(eg,eg$Exp, function(x) aov(masa.uscat.tr~Clona,data=x))

I want to compute Anova summary for each experiment (exp) and I want to compute Tuckey test for each Anova.

Thank you very much!

My data is like this:



Exp Plot Clona Prov masa uscat tr masa usc. Ram masa usc total B 36 Max4 P Puieti 6.199848485 2.639325843 8.839174328 B 36 Max4 P Puieti 3.87875 1.4798 5.35855 B 36 Max4 P Puieti 7.822702703 3.32852071 11.15122341 B 36 Max4 P Puieti 5.645384615 1.995238095 7.640622711 B 36 Max4 P Puieti 10.2 3.514864865 13.71486486 B 36 Max4 P Puieti 8.815545455 3.35627907 12.17182452 B 36 Max4 P Puieti 5.033333333 1.607142857 6.64047619 B 36 Max4 P Puieti 6.693488372 2.630208333 9.323696705 B 36 Max4 P Puieti 6.021012658 1.60293578 7.623948438 B 36 Max4 P Puieti 10.20582524 3.768314607 13.97413985 B 33 Max4 Butasi 5.899417476 1.745394737 7.644812213 B 33 Max4 Butasi 3.261428571 1.335735294 4.597163866 B 33 Max4 Butasi 3.359508197 1.456641221 4.816149418 B 33 Max4 Butasi 5.036363636 2.097793103 7.13415674 B 33 Max4 Butasi 3.122162162 1.612012579 4.734174741 B 33 Max4 Butasi 5.042474227 3.246916427 8.289390653 B 33 Max4 Butasi 5.058255814 2.724299065 7.782554879 B 33 Max4 Butasi 4.977818182 1.713504274 6.691322455 B 33 Max4 Butasi 3.195294118 1.243411765 4.438705882 B 33 Max4 Butasi 1.831818182 1.009090909 2.840909091 B 30 AF2 Butasi 6.98195122 1.764 8.74595122 B 30 AF2 Butasi 5.858333333 1.686623377 7.54495671 B 30 AF2 Butasi 10.625 3.04 13.665 C 39 AF6 Sade 10.27125 2.283193277 12.55444328 C 39 AF6 Sade 9.473488372 1.909414414 11.38290279 C 39 AF6 Sade 10.4825 2 12.4825 C 39 AF6 Sade 11.61579545 2.431136364 14.04693182 C 39 AF6 Sade 8.185074627 1.809333333 9.99440796 C 39 AF6 Sade 11.04510638 2.23672956 13.28183594 C 39 AF6 Sade 9.066666667 2.473785714 11.54045238 C 39 AF6 Sade 10.12787611 3.097631579 13.22550769 C 39 AF6 Sade 9.171290323 1.821226415 10.99251674 C 39 AF6 Sade 12.1846875 2.262590361 14.44727786 C 42 Pannonia Sade 9.275 2.482173913 11.75717391 C 42 Pannonia Sade 7.21 1.77 8.98 C 42 Pannonia Sade 11.36939394 3.111780822 14.48117476 C 42 Pannonia Sade 7.85296875 1.943475177 9.796443927 C 42 Pannonia Sade 8.25 2.54047619 10.79047619 C 42 Pannonia Sade 8.669277108 2.187071429 10.85634854 C 42 Pannonia Sade 8.510886076 2.05344 10.56432608 C 42 Pannonia Sade 9.362222222 5.525531915 14.88775414 C 42 Pannonia Sade 11.08481928 2.573193277 13.65801255 C 42 Pannonia Sade 10.17462687 3.003225806 13.17785267 C 45 Monviso Sade 12.99693878 3.216083916 16.21302269 C 45 Monviso Sade 11.11456522 1.885714286 13.0002795 C 45 Monviso Sade 8.129333333 1.532666667 9.662 C 45 Monviso Sade 9.943043478 2.38300885 12.32605233 C 45 Monviso Sade 11.9805814 3.080923913 15.06150531 C 45 Monviso Sade 10.31376623 2.210526316 12.52429255 C 45 Monviso Sade 9.947586207 1.860833333 11.80841954 C 45 Monviso Sade 12.24261538 2.166857143 14.40947253 C 45 Monviso Sade 13.56650602 2.414371257 15.98087728 C 45 Monviso Sade 10.87574257 2.922340426 13.798083 C 48 AF2 Sade 9.334545455 2.201822917 11.53636837 C 48 AF2 Sade 9.747640449 2.811780822 12.55942127 C 48 AF2 Sade 14.29541284 4.506885246 18.80229809 C 48 AF2 Sade 10.26451613 3.014322581 13.27883871 C 48 AF2 Sade 13.30924242 3.960661765 17.26990419 C 48 AF2 Sade 13.23228426 5.00546875 18.23775301 C 48 AF2 Sade 14.8277027 4.450447761 19.27815046 C 48 AF2 Sade 15.23669528 7.559322034 22.79601731 C 48 AF2 Sade 13.27198582 3.758252427 17.03023824 C 48 AF2 Sade 13.71364444 5.690444444 19.40408889 C 51 Max4 Sade 8.860884956 5.613586957 14.47447191 C 51 Max4 Sade 13.29153285 5.653061224 18.94459407 C 51 Max4 Sade 9.609850746 3.385714286 12.99556503

--
---
Catalin-Constantin ROIBU
Lecturer PhD, Forestry engineer
Forestry Faculty of Suceava
Str. Universitatii no. 13, Suceava, 720229, Romania
office phone     +4 0230 52 29 78, ext. 531
mobile phone   +4 0745 53 18 01
                       +4 0766 71 76 58
FAX:                +4 0230 52 16 64
silvic.usv.ro

        [[alternative HTML version deleted]]

______________________________________________
R-help op 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.
* * * * * * * * * * * * * D I S C L A I M E R * * * * * * * * * * * * *
Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver weer en binden het INBO onder geen enkel beding, zolang dit bericht niet bevestigd is door een geldig ondertekend document.
The views expressed in this message and any annex are purely those of the writer and may not be regarded as stating an official position of INBO, as long as the message is not confirmed by a duly signed document.



More information about the R-help mailing list