I am getting the error saying
lsmDrugs=lsmeans(model1, -drug) Error in -drug : invalid argument to unary operator"
Any help please?
library(knitr)
library(lsmeans)
drug <- c(rep("A", 2),rep("B", 2),rep("C", 2))
drugDiff <- c(-14, -4, 5, -1, -2, 6)
data<-data.frame(Drug=as.factor(drug),Difference=drugDiff)
data
model1 <- aov(drugDiff ~ drug, data = data)
anova(model1)
kable(anova(model1), format = "markdown")
lsmDrugs = lsmeans(model1, -drug)
summary(contrast(lsmDrugs, method="pairwise",
adjust = "tukey"), infer = c(T, T), level = 0.95, side = "twosided")
You have a typo as you should use tilde -
~
instead of-
charachter. Tildes are used for formulas in R. Please see the code below:Output: