Learn R Programming

aridagri (version 2.0.3)

anova_factorial: Factorial ANOVA (Two-Factor)

Description

Performs two-factor factorial ANOVA with interaction analysis.

Usage

anova_factorial(
  data,
  response,
  factor1,
  factor2,
  replication = NULL,
  posthoc = "lsd",
  alpha = 0.05,
  verbose = TRUE
)

Value

List containing ANOVA results

Arguments

data

Data frame containing the data

response

Name of the response variable

factor1

Name of first factor (A)

factor2

Name of second factor (B)

replication

Name of replication factor (optional)

posthoc

Post-hoc test method

alpha

Significance level

verbose

Logical. If TRUE (default), prints formatted output to console.

Author

Lalit Kumar Rolaniya, ICAR-IIPR, Bikaner

Examples

Run this code
data <- expand.grid(
  rep = 1:4,
  nitrogen = c("N0", "N40", "N80", "N120"),
  phosphorus = c("P0", "P30", "P60")
)
data$yield <- rnorm(nrow(data), 1200, 150)

anova_factorial(data, response = "yield", 
                factor1 = "nitrogen", factor2 = "phosphorus",
                replication = "rep")

Run the code above in your browser using DataLab