tudo bem? Estou tentando fazer um gráfico de interação no R usando o pacote ggplot2, no entanto o seguinte erro está ocorrendo
Aesthetics should be the length 1 or the same as the data (1983): color.
Alguém pode me ajudar?
Data base: http://halweb.uc3m.es/esp/Personal/personas/durban/esp/web/cursos/Maringa/gam-markdown/index.html
Os dados estão na seção data.zip, a base dados é a leukemia.txt. Note: Eu estou utilizando as seguintes librarys:
library(nlme) library(ggplot2) library(GGally) library(splines) library(nlme) library(fields) library(lattice) require(ISLR) library(grid) library(dplyr) library(MASS) library(mgcv) library(latticeExtra) library(fields)
Segue o código abaixo:
setwd("C:\Users\breni\Google Drive\Acadêmica\Mestrado\Splines") dados <- read.table("leukemia.txt", header=TRUE) dados$ treatment <- factor(dados$ treatment) dados$ case <- factor(dados$ case) head(dados) attach(dados) interaction <- dados %>% dplyr::select(height, age, case) %>% group_by(case, age) %>% summarise(Average = mean(height)) x11() ggplot(interaction, aes(x=age, y=Average, colour=treatment, group=case)) + ggtitle("Evolução da altura em cm no tempo para cada individuo") + geom_line()