How to fix error "can not coerce class" "group" "to a data.frame"

1

When running script below, specifically in the playback part of data.frames , the error was returned:

  

Error in as.data.frame.default (x [[i]], optional = TRUE,   stringsAsFactors = stringsAsFactors):         can not 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)

#---------------------------------------------------------------------------
# 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)
    
asked by anonymous 17.09.2018 / 21:43

0 answers