[R] How to code the factor for ANOVA

Bert Gunter bgunter.4567 at gmail.com
Mon Jun 26 07:47:18 CEST 2017


You really really need to go through one of the many R (web) tutorials
where this is discussed in detail. Or see the Intro to R tutorial that
ships with R. This is not the proper venue for learning how R handles
linear models and how its formula interface works. A terse treatment
can be found in ?lm, ?aov, and ?formula and links therein, but a
suitable tutorial would probably be a better alternative.

Cheers,
Bert


Bert Gunter

"The trouble with having an open mind is that people keep coming along
and sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )


On Sun, Jun 25, 2017 at 10:05 PM, Jinsong Zhao <jszhao at yeah.net> wrote:
> Hi there,
>
> I have a experimental design related question. I have done a experiment with
> 3 factors. The design matrix is similar to:
>
>> data.frame(Factor.1 = rep(rep(0:2, each = 3),3), Factor.2 =
>
> rep(c("U","S","N"), 9), Factor.3 = rep(0:2, each = 9))
>    Factor.1 Factor.2 Factor.3
> 1         0        U        0
> 2         0        S        0
> 3         0        N        0
> 4         1        U        0
> 5         1        S        0
> 6         1        N        0
> 7         2        U        0
> 8         2        S        0
> 9         2        N        0
> 10        0        U        1
> 11        0        S        1
> 12        0        N        1
> 13        1        U        1
> 14        1        S        1
> 15        1        N        1
> 16        2        U        1
> 17        2        S        1
> 18        2        N        1
> 19        0        U        2
> 20        0        S        2
> 21        0        N        2
> 22        1        U        2
> 23        1        S        2
> 24        1        N        2
> 25        2        U        2
> 26        2        S        2
> 27        2        N        2
>
> The Factor.2 indicates the type of a fertilizer, such as urea, and the
> Factor.3 indicates the weight of the fertilizer. So the treatments with
> Factor.3 == 0 at each levels of Factor.1 are same. That means No.1, No.2 and
> No.3 are same, No.4, No.5 and No.6 are same, and No.7, No.8 and No.9 are
> same. Thus, in the real experiment, those treatments were not performed as
> stated in the design matrix. For instance, only No.1, No.5 and No.9 are
> performed.
>
> In the case, how to code the factor for ANOVA? I really appreciate any
> comments and suggestions. Thanks in advance.
>
> Best regards,
> Jinsong
>
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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.



More information about the R-help mailing list