[英]How to plot multiple lines with several conditions (6*2*3) in R
我正在嘗試繪制此數據框,該數據框共有36行* 7列:注意:
stim_ending_t = 1、1.5、2、2.5、3、3.5有6個因素
三是三個重復的條件:
visbility =1 soundvolume=0 (visbility)
visbility =0 soundvolume=1 (soundvolume)
visbility = 0 soundvolume=0 (this sould be called blank or empty)
日期框架名稱:master_all_r.csv
stim_ending_t visbility soundvolume Opening_text m sd coefVar
<dbl> <dbl> <dbl> <chr> <dbl> <dbl> <dbl>
1 1 0 0 Now focus on the Image 1.70 1.14 0.670
2 1 0 0 Now focus on the Sound 1.57 0.794 0.504
3 1 0 1 Now focus on the Image 1.62 1.25 0.772
4 1 0 1 Now focus on the Sound 1.84 1.17 0.637
5 1 1 0 Now focus on the Image 3.19 17.2 5.38
6 1 1 0 Now focus on the Sound 1.59 0.706 0.444
該圖應如何顯示: x = Stim_ending_t,y = m
我需要在同一繪圖中滿足上述條件的三行,並由= Opening_text分為兩組。 如果可能的話,它可以放在一個圖中,但如果沒有,則可以將兩組(現在集中在圖像上,現在集中在聲音上)分成兩個單獨的圖。
我已經試過這段代碼:
ggplot(test_master, aes(x=stim_ending_t, y=m, group=Opening_text, visbility, soundvolume)) +
geom_line(aes(linetype=Opening_text, visbility, soundvolume))+
geom_point()
但是得到了這樣的Warning message: Duplicated aesthetics after name standardisation:
這就是我得到的結果
理想情況下,該圖應看起來像這樣,但此處有三行。 我在這里找到這些地塊
如果要下載excel文件,可以在此處找到它,名稱為master_all_r.csv。
我相信您正在尋找這樣的東西:
library(tidyvere)
library(readr)
test_master <- read_csv("https://raw.githubusercontent.com/MohJumper/VisualAuditoryModality/master/master_all_r.csv")
test_master %>%
mutate(visbility_sound = case_when(
visbility == 1 & soundvolume == 0 ~ "visibility",
visbility == 0 & soundvolume == 1 ~ "soundvolume",
visbility == 0 & soundvolume == 0 ~ "empty")) %>%
mutate_at(vars(visbility_sound), factor) %>%
ggplot(aes(x = stim_ending_t, y = m, color = visbility_sound)) +
geom_line(aes(linetype = visbility_sound)) +
geom_point() +
facet_wrap(~Opening_text) +
theme_minimal()
所以這是正在發生的事情:
geom_line
也將此列用於線型 facet_wrap
(也可以使用facet_grid
!)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.