I ran into a little problem when using the multcompBoxplot
function in multocompView
. The following code runs perfectly fine:
set.seed(1000)
Data<-c(runif(20, min=0, max=0.4), runif(20, min=0.1, max=0.6), runif(20, min=0.2, max=1))
Names<-c(rep("Type.1", 20), rep("Type.2", 20), rep("Type.3", 20))
Data<-cbind.data.frame(Data, Names, stringsAsFactors=FALSE)
Data[,2]<-as.factor(Data[,2])
colnames(Data)<-c("Success", "Type")
boxplot(Success~Type, data=Data)
library(multcompView)
multcompBoxplot(Success~Type, data=Data)
However, this is using the default setting for compFn
which is "TukeyHSD". My p-values would come from another function. According to the manual, compFn
is
a function whose output will serve as the the only non-default input to either ’multcompTs’ or ’multcompLetters’. The default "TukeyHSD" actually translates to ’TukeyHSD(aov(formula, data))[[1]][, "p adj"]’.
So, TukeyHSD(aov(formula, data))[[1]][, "p adj"]
returns a vector with p-values for each possible pairwise comparisons. Those p-values, which I have formatted exactly alike from another source are then passed to multcompLetters
and multcompTS
for the respective calculations of those functions. If I just do this manually, everything works fine:
P.Adj<-TukeyHSD(aov(Success~Type, data=Data))[[1]][, "p adj"]
Species.Groups<-multcompLetters(P.Adj, threshold=0.05)
Species.T<-multcompTs(P.Adj, threshold=0.05)
But as soon as I try to provide the exactly same information within multcompBoxplot
, I get warnings and a broken output displaying neither the T's nor the letters:
multcompBoxplot(Success~Type, data=Data, compFn=P.Adj)
Error in do.call(Fn, list(formula = formula, data = data)) :
'what' must be a character string or a function
In addition: Warning messages:
1: In if (compFn == "TukeyHSD") { :
the condition has length > 1 and only the first element will be used
2: In if (compFn == "kruskalmc") { :
the condition has length > 1 and only the first element will be used
As I understand the manual, this should provide exactly the data the function needs. So does multcompBoxplot
simply not work with providing the results instead of the function to calculate them, or am I doing something wrong?