[英]R code: When I draw a line graph including multiple lines in R, one of them cannot fully be displayed
[英]Lines do not fully connect in line graph in R
我正在尝试创建一个显示 Go/No-go 任务的响应时间的折线图。 我遇到了线路问题,因为它们没有连接到预期值。 我只希望“通过”都是一条线,而“禁止”是一条线。 有谁知道如何纠正这个? 我已经包含了折线图当前的外观和数据集的示例。 谢谢你!
> ggplot(response_times, aes(x = day, y = mean, group = 2)) +
geom_line(aes(color = trialtype)) +
geom_point(aes(color = trialtype)) +
theme(axis.text.x = element_text(angle = 60)) +
labs(title="Average response time of Go/No-go Trials",
x = "Date of training",
y = " Average Response Time ")
我试图从照片中复制你的例子,我没有得到所有的数字,因为我是手工复制的,但是,还是看看:
day <- rep(c("2022-06", "2022-07", "2022-08", "2022-09",
"2022-10", "2022-11", "2022-12", "2022-13",
"2022-14", "2022-15", "2022-16", "2022-17",
"2022-18", "2022-19", "2022-20", "2022-21"))
trialtype <- as.factor(rep(c("go", "no-go"), 16, by = 2))
# mean <- data$CONT_Y[1:8]
mean <- c(0.49, 0.54, 0.44, 0.40, 0.44, 0.34, 0.45, 0.46,
0.42, 0.47, 0.46, 0.45, 0.26, 0.47, 0.41, 0.48)
mydata <- data.frame(day = day,
trialtype = trialtype,
mean = mean)
mydata %>%
ggplot(., aes(x = day, y = mean, group = trialtype)) +
geom_line(aes(color = trialtype)) +
geom_point(aes(color = trialtype)) +
theme(axis.text.x = element_text(angle = 60)) +
labs(title="Average response time of Go/No-go Trials",
x = "Date of training",
y = " Average Response Time ")
plot:
下次,如果可能的话,而不是图片,那么也许你可以通过 github 或 dput() 分享 dataframe (我仍然不知道如何使用 dput,但我也被要求通过它上传: )
根据 Ben 的评论,我刚刚将group = 2
更改为group = trialtype
(对不起,我发帖后刚刚检查了评论,如果好的做法我可能会删除答案,我也是论坛的新手)
group = 2
得到的:)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.