plotLSDerrors.data.frame | R Documentation |
Produces a plot of the errors that have been supplied in a data.frame
.
The data.frame
includes two factors whose levels specify,
for each LSD result, which combinations of factor levels are being compared. The function
plotLSDerrors.alldiffs
produces such data.frame
s.
## S3 method for class 'data.frame'
plotLSDerrors(object, LSDresults = "LSDresults", x, y,
alpha = 0.05, triangles = "both",
gridspacing = 0, title = NULL,
axis.labels = NULL, axis.text.size = 12,
colours = c("white","blue","red","grey"),
ggplotFuncs = NULL, printPlot = TRUE, ...)
object |
A |
LSDresults |
A |
x |
A |
y |
A |
alpha |
A |
triangles |
A |
gridspacing |
A |
title |
A |
axis.labels |
A |
axis.text.size |
A |
colours |
A vector of colours to be passed to the |
ggplotFuncs |
A |
printPlot |
A |
... |
Provision for passing arguments to functions called internally - not used at present. |
An object of class "ggplot
", which can be plotted using print
or otherwise manipulated.
Chris Brien
plotLSDs.data.frame
, plotLSDs.alldiffs
,
exploreLSDs
, ggplot
##Subset WaterRunoff data to reduce time to execute
data(WaterRunoff.dat)
tmp <- subset(WaterRunoff.dat, Date == "05-18")
##Use asreml to get predictions and associated statistics
## Not run:
asreml.options(keep.order = TRUE) #required for asreml-R4 only
current.asr <- asreml(fixed = pH ~ Benches + (Sources * (Type + Species)),
random = ~ Benches:MainPlots,
keep.order=TRUE, data= tmp))
current.asrt <- as.asrtests(current.asr, NULL, NULL)
TS.diffs <- predictPlus.asreml(classify = "Sources:Type",
asreml.obj = current.asr, tables = "none",
wald.tab = current.asrt$wald.tab,
present = c("Type","Species","Sources"))
## End(Not run)
## Use lmeTest and emmmeans to get predictions and associated statistics
if (requireNamespace("lmerTest", quietly = TRUE) &
requireNamespace("emmeans", quietly = TRUE))
{
m1.lmer <- lmerTest::lmer(pH ~ Benches + (Sources * (Type + Species)) +
(1|Benches:MainPlots),
data=na.omit(WaterRunoff.dat))
TS.emm <- emmeans::emmeans(m1.lmer, specs = ~ Sources:Type)
TS.preds <- summary(TS.emm)
den.df <- min(TS.preds$df, na.rm = TRUE)
## Modify TS.preds to be compatible with a predictions.frame
TS.preds <- as.predictions.frame(TS.preds, predictions = "emmean",
se = "SE", interval.type = "CI",
interval.names = c("lower.CL", "upper.CL"))
## Form an all.diffs object and check its validity
TS.vcov <- vcov(TS.emm)
TS.diffs <- allDifferences(predictions = TS.preds, classify = "Sources:Type",
vcov = TS.vcov, tdf = den.df)
validAlldiffs(TS.diffs)
}
## Plot LSD values for predictions obtained using asreml or lmerTest
if (exists("TS.diffs"))
{
LSDresults <- within(reshape2::melt(TS.diffs$p.differences),
{
Var1 <- factor(Var1, levels=dimnames(TS.diffs$p.differences)[[1]])
Var2 <- factor(Var2, levels=levels(Var1))
})
names(LSDresults) <- c("Rows","Columns","LSDresults")
plotLSDerrors(LSDresults, x = "Rows", y = "Columns", gridspacing = rep(c(3,4), c(4,2)))
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.