Description Usage Arguments Value Examples
Use Finlay-Wilkinson test to test for GxE interaction by comparing (GE ~ Location mean) regression coefficient against a slope of 1.
1 | fw_test(GE_dat, Loc_dat, plot_GE = as.numeric(NA), test_slope = 1)
|
GE_dat |
A data.frame containing yield values for each GE at tested locations. The first two columns must be 'GE' and 'Year', followed by columns of yield data at each location. See example data below. |
Loc_dat |
A data.frame of location means for each location in GE_dat. Col names: 'Loc', 'Year', 'Loc_mean'. |
plot_GE |
(optional) A numeric GE ID to be plotted. |
test_slope |
The slope that the FW test should be performed against (default = 1). |
If plot_GE is not specified: returns a data.frame containing a slope and p-value for each GE/Year combination.
If plot_GE is specified: returns a list, where the first element is a data.frame of slopes and p-values for all GE/Year combinations, and the second element
is a gtable containing the plot for the specified GE. The plot can be drawn using grid::grid.draw(list_name[2]).
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | set.seed(1)
ge <- matrix(rnorm(405, c(75, 78)), nrow = 27, ncol = 15) %>%
as.data.frame() %>%
stats::setNames(paste0("Loc", seq(1, 15))) %>%
dplyr::mutate(GE = rep(1:9, each = 3),
Year = rep(2018:2020, times = 9)) %>%
dplyr::select(GE, Year, everything())
loc <- plyr::ddply(ge, "Year", function (Year_group) {
purrr::map_dfr(Year_group[, 3:ncol(Year_group)], mean)
}) %>%
tidyr::gather(key = "Loc", value = "Loc_mean", -Year) %>%
dplyr::select(Loc, Year, Loc_mean)
results <- fw_test(ge, loc, 6)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.