[R] How to troubleshoot error “cannot coerce class ”“group”“ to a data.frame”?

Fabiano França f@bi@no@fr@nc@d@ @ending from hotm@il@com
Tue Sep 18 04:34:30 CEST 2018


Dear Volunteers,
When running the scriptbelow, specifically in the part of reproduction of the data.framesreturned the error:

Error in as.data.frame.default(x[[i]], optional = TRUE, stringsAsFactors = stringsAsFactors) : cannot coerce class ""group"" to a data.frame

I searched the internet and could not reproduce the suggestions for my case, does anyone tell 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)#---------------------------------------------------------------------------# unfolding the interaction in Tukey tests

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)

Many thanks

Regards,

Fabiano Fran�a da Silva
Doutorando em Fitotecnia - ESALQ/USP
MSc Fitotecnia - UFLA
Eng�. Agr�nomo - UFLA
(35) 9 9155-5443 TIM



	[[alternative HTML version deleted]]



More information about the R-help mailing list