[R-br] Error: Aesthetics

gabriel henrique pires de mello ribeiro gabrielgiga em gmail.com
Quinta Agosto 4 10:49:29 BRT 2016


Prezados listeiros, antes de atualizar o R para a versão 3.3.1, o script
abaixo rodava sem erros (apenas um Warning). segue a estrutura dos dados

require(car)
require(compute.es)
require(effects)
require(ggplot2)
require(multcomp)
require(pastecs)
require(WRS2)
require(extrafont)
require(scales)

str(d)
'data.frame': 60 obs. of  13 variables:
 $ Top    : Factor w/ 2 levels "P","V": 2 2 2 2 2 2 2 2 2 2 ...
 $ nome2  : Factor w/ 3 levels "Eschweilera_spp",..: 3 3 3 3 3 3 3 3 3 3 ...
 $ Stem   : num  1212 896 769 935 477 ...
 $ Crown  : num  650 499 199 344 129 ...
 $ AGB    : num  1862 1395 967 1279 606 ...
 $ HT     : num  27.9 26.1 25.7 26.8 20.6 ...
 $ DBH    : num  34.6 31.6 27.6 29.8 24.5 20 38.8 35 38.1 19.5 ...
 $ Center : num  11.61 10.86 9.48 10.8 8.14 ...
 $ failure: Factor w/ 2 levels "snap","uprooted": 1 1 1 1 1 1 1 1 1 1 ...
 $ CTM    : num  260554 197344 131775 195757 133708 ...
 $ SWD    : num  0.9 0.79 0.84 0.82 0.82 0.92 0.81 0.83 0.86 0.9 ...
 $ slender: num  80.7 82.6 93.1 90 84.1 ...
 $ grain  : Factor w/ 3 levels "cross","interlocked",..: 3 3 3 3 3 3 3 3 3
3 ...

####SCRIPT###########
lb1 <- expression(paste(M[crit]~'(kN-m)')) # Critical turning moment
lb2 <- expression(paste("AGB (kg)")) # biomass


plot7 <- ggplot(d, aes(x = AGB, y = CTM/1000, col = grain, group =
grain,colour=d[,"grain"], shape=d[,"grain"],linetype=d[,"grain"])) +
  geom_point(size = 3) +
  geom_smooth(method = "lm", group = d$grain, se = F) +
  stat_smooth(method="lm")+
  ylab(lb1) +
  xlab(lb2) +
  scale_y_continuous(limits = c(0, 400)) +
  labs(colour = "grain", shape="grain",linetype="grain") +
  guides(colour = guide_legend(title="Type of grain"),
         linetype=guide_legend(title="Type of grain"),
         shape=guide_legend(title="Type of grain")) +
  scale_shape_manual(values = c(15,16,17)) +
  scale_colour_manual(values = c("black","red","blue"))+
  scale_linetype_manual(values=c("dashed","solid","dotted"))+
  theme_bw() + theme_classic()+ theme(text=element_text(family="CM Roman",
face="bold")) +
  theme(axis.text=element_text(size=18),axis.title=element_text(size=18),

legend.text=element_text(size=16),legend.title=element_text(size=14))+
  theme(legend.justification = 'right', legend.position=c(0.29,0.85))

plot7 #+ annotate("text", x = 0.4, y = 370, label = "Intercept test\np -
value\n0.00438",size=6,family="CM Roman")

Após rodar o script aparece a seguinte mensagem
*(Warning message:The plyr::rename operation has created duplicates for the
following name(s): (`colour`) > plot7 #+ annotate("text", x = 0.4, y = 370,
label = "Intercept test\np - value\n0.00438",size=6,family="CM Roman")*
*Error: Aesthetics must be either length 1 or the same as the data (240):
group.*

*Desde já agradeço qualquer comentário, abr*
*Gabriel Ribeiro*
-------------- Próxima Parte ----------
Um anexo em HTML foi limpo...
URL: <http://listas.inf.ufpr.br/pipermail/r-br/attachments/20160804/0f78441c/attachment.html>


Mais detalhes sobre a lista de discussão R-br