I want to plot my data each time in two different plots one for pre and one for post data and in each plot the x axis will represent the sub id and the Y axis the response error. I want the data to be grouped by the Group factor.
I have tried the following. mytheme3 <- theme(legend.text = element_text(face = "italic",colour="black", family = "Helvetica", size = rel(1)), axis.title = element_text(colour="black",family = "black", size = rel(1)), axis.text = element_text(family = "black",colour = "black", size = rel(1)), axis.line = element_line(size = 1,colour = "black"), axis.ticks = element_line(colour="grey",size = rel(1)), # panel.grid.major = element_line(colour="grey",size = rel(0.5)), # panel.grid.minor = element_blank(), panel.background = element_rect(fill = "white"), legend.key = element_rect(fill = "white"), legend.title = element_text(colour = "steelblue",size = rel(1), family = "Helvetica"), plot.title = element_text(colour = "steelblue4", face = "bold", size = rel(1.5),family = "Helvetica"))
if (mazeData$Session == 'Session1' & mazeData$Condition == 'SR') {
plot1<-ggplot(mazeData, aes(Errorfixed,SubjectID,colour=Group))+geom_point() + mytheme3+
ggtitle("Error for test1") + labs(y="Subject ID", x = "Error (degrees)", colour = "Group") +
scale_colour_manual(values = c("deeppink", "blue", "black"))
} else if (mazeData$Session == 'Session2' & mazeData$Condition == 'SR') {
plot2<-ggplot(mazeData, aes(Errorfixed,SubjectID,colour=Group))+geom_point() + mytheme3+
ggtitle("Error for test2") + labs(y="Subject ID", x = "Error (degrees)", colour = "Group") +
scale_colour_manual(values = c("deeppink", "blue", "black"))
}
ggplot2.multiplot (plot1, plot2, cols = 2)
I get this error:
Warning messages:
1: In if (mazeData$Session == "Session1" & mazeData$Condition == "SR") { :
the condition has length > 1 and only the first element will be used
2: In if (mazeData$Session == "Session2" & mazeData$Condition == "SR") { :
the condition has length > 1 and only the first element will be used
How can I vectorize my factors? or solve this error anyway?
Thank you in advance!!
Aucun commentaire:
Enregistrer un commentaire