1
When rotating the script
below, specifically in the part of reproduction of data.frames
error was returned:
Error in as.data.frame.default(x[[i]], optional = TRUE, stringsAsFactors = stringsAsFactors) : cannot coerce class ""group"" to a data.frame
I looked on the internet and could not reproduce the suggestions for my case, someone shows me a way?
setwd("https://drive.google.com/open?id=1FDMZfWrEjsvleVdNOUiPh8REGjvQHKQx")
rend <- read.table('IVCM.txt', header = TRUE, sep="\t")
rend <- transform(rend, Fungicidas=factor(Fungicidas), Doses=factor(Doses), Rep=factor(Rep))
str(rend)
#---------------------------------------------------------------------------
# desdobrando a interação em testes de Tukey
require(agricolae)
require(plyr)
KinA <- sapply(levels(rend$Doses), simplify=FALSE,
function(Doses){
with(subset(rend, Doses==Doses),
HSD.test(IVCM, Fungicidas,
DFerror=df.residual(m0),
MSerror=deviance(m0)/df.residual(m0)))
})
KinA <- llply(KinA, NULL)
KinA$M <- gsub(" ", "", KinA$M, fixed=TRUE)
KinA$trt <- as.factor(as.numeric(as.character(KinA$trt)))
str(KinA)
AinK <- sapply(levels(rend$Fungicidas), simplify=FALSE,
function(Fungicidas){
with(subset(rend, Fungicidas==Fungicidas),
HSD.test(IVCM, Doses,
DFerror=df.residual(m0),
MSerror=deviance(m0)/df.residual(m0)))
})
AinK <- llply(AinK, NULL)
AinK$M <- toupper(gsub(" ", "", AinK$M, fixed=TRUE))
AinK$trt <- as.factor(as.numeric(as.character(AinK$trt)))
str(AinK)
#---------------------------------------------------------------------------
# combinando os data.frames para obter o gráfico e a tabela
KinA$comb <- paste(KinA$trt, KinA$.id)
AinK$comb <- paste(AinK$.id, AinK$trt)
desd <- merge(KinA, AinK, by=c("comb","comb"))
desd$let <- with(desd, paste(M.y, M.x, sep=""))
desd <- desd[,c("trt.x","trt.y","means.x","let")]
names(desd) <- c("Fungicidas","Doses","means","let")
str(desd)
Welcome to Stackoverflow! Unfortunately, this question cannot be reproduced by anyone trying to answer it. Please, take a look at this link and see how to ask a reproducible question in R. So, people who wish to help you will be able to do this in the best possible way.
– Marcus Nunes
The link https://drive.google.com/open?id=1JdgsnJn5VrkL8j1BsfWzqYW9fMGXND6U leads to a table that does not have the columns that are expected by the script. That’s right?
– Daniel Falbel
Link updated @Danielfalbel. This is the file: https://drive.google.com/open?id=1FDMZfWrEjsvleVdNOUiPh8REGjvQHKQx
– Fabiano França
@Fabianofrança Gives error:
Error in deviance(m0) : objeto 'm0' não encontrado
.– Rui Barradas
@Fabianofrance Fit a linear model such as
m0 <- lm(IVCM ~ Fungicidas + Doses, rend)
gives its mistake and the problem is thatmerge
is for class objects"data.frame"
so muchclass(KinA)
asclass(AinK)
sane[1] "list"
. Besides, I see no reason to runKinA <- llply(KinA, NULL)
and thegsub
of the following line and the same forllply(AinK, etc)
.– Rui Barradas
@Noisy was made the model adjustment and checking, which is
m0 <- aov(IVCM~Rep+Doses*Fungicidas, data=rend)
summary(m0)
par(mfrow=c(2,2)); plot(m0); layout(1)
. Even so, the error persists.– Fabiano França
@Fabianofrance Thank you for the reply. But see in my second comment that the main error does not come from the model, but from the values of
HSD.test
who are inKinA
and inAinK
, more exactly, the type of data ("list"
) thatHSD.test
produces. The functionmerge
unaccepted lists.– Rui Barradas
@Noisy really, thanks for the tips. I’ll try another way to run the statistics. Grateful!
– Fabiano França