subset.alldiffs {asremlPlus}R Documentation

Subsets the components in an alldiffs.object according to the supplied condition.


Subsets each of the components of an alldiffs.object. The subset is determined by applying the condition to the prediction component to determine which of its rows are to be included in the subset. Then, if present, this subset is applied to the rows of backtransforms and to the rows and columns of differences, p.differences and sed components. In addition, if sed is present, recalcLSD.alldiffs is called to recalculate the values in the LSD component, with any arguments supplied via the ... argument passed ot it.

The select argument of subset is not implemented, but can be achieved for variables in the classify using the rmClassifyVars argument.


## S3 method for class 'alldiffs'
subset(x, subset = rep(TRUE, nrow(x$predictions)), 
       rmClassifyVars = NULL, ...)



An alldiffs.object.


A logical that detemines rows of the predictions component of x to be included in the subset. By default allws are included.


A character that contains the names of the variables in the classify attribute of x that are to be removed from the predictions data.frame and the names of the dimensions of the other components of x. In doing this, the combinations of the remaining classify variables must uniquely index the predictions.


further arguments passed to recalcLSD.alldiffs.


An alldiffs.object with the following components of the supplied alldiffs.object subsetted, if present in the original object: predictions, vcov, backtransforms, differences, p.differences and sed. In addition, if sed is present, the LSD component will be recalculated.


Chris Brien

See Also

as.alldiffs,, print.alldiffs, sort.alldiffs,
redoErrorIntervals.alldiffs, recalcLSD.alldiffs,
predictPlus.asreml, predictPresent.asreml



##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= WaterRunoff.dat)
current.asrt <- as.asrtests(current.asr, NULL, NULL)
TS.diffs <- predictPlus.asreml(classify = "Sources:Type", 
                              asreml.obj = current.asr, tables = "none", 
                     = current.asrt$, 
                              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)) + 
  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)

## Plot p-values for predictions obtained using asreml or lmerTest
if (exists("TS.diffs"))
  ##Use subset.alldiffs to select a subset of the alldiffs object
  TS.diffs.subs <- subset(TS.diffs, 
                          subset = grepl("R", Sources, fixed = TRUE) & 
                                   Type %in% c("Control","Medicinal"))

[Package asremlPlus version 4.2-32 Index]