If statement 使用if-else参数绘制多个因子
我希望每次在两个不同的图中绘制我的数据,一个用于前数据,一个用于后数据,在每个图中,If statement 使用if-else参数绘制多个因子,if-statement,plot,vectorization,If Statement,Plot,Vectorization,我希望每次在两个不同的图中绘制我的数据,一个用于前数据,一个用于后数据,在每个图中,x轴表示子id,Y轴表示响应错误。我希望数据按分组系数分组 我试过以下方法 mytheme3 <- theme(legend.text = element_text(face = "italic",colour="black", family = "Helvetica&
x
轴表示子id,Y
轴表示响应错误。我希望数据按分组系数分组
我试过以下方法
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)
如何将我的因子矢量化?还是解决这个错误
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