title: "view_ggline"
author: "wishing"
date: "20220906"
output: word_document
knitr::opts_chunk$set(echo = TRUE)
getwd()
#设置工作路径
setwd("D:/desk/speed/data_1/behavior/R")
#导入数据
library(xlsx)
data0=read.xlsx("allspeed_0.xlsx",1)
#print(data0)
library(xlsx)
data1=read.xlsx("lapse800_long.xlsx",1)
#print(data1)
#剔除被试5,8,9,14,23,32
data2=data1[data1$id!=5&
data1$id!=8&
data1$id!=9&
data1$id!=14&
data1$id!=23&
data1$id!=32,]
#导出数据
write.xlsx(data2, "lapse800long_out.xlsx")
write.xlsx(data3, "speedlong_out.xlsx")
#描述性统计
library(psych)
myvars= c("norate","corate","meanrt","fastrt")
describe(data0[myvars])
library(psych)
myvars= c("lapse")
describeBy(data1[myvars],list(time=data1$time))
describeBy(data1[myvars],list(speed=data1$speed))
describeBy(data2[myvars],list(time=data2$time))
describeBy(data2[myvars],list(speed=data2$speed))
library(bruceR)
Describe(data3)
Describe(data2)
#折线图lapse
library(ggplot2)
library(ggpubr)
ggline(data2,x="time",y="lapse",palette="lancet",width = 0.5,
order = c("RW","SD"), add=c("mean_se"), error.plot="errorbar",
lab.vjust =-0.2,lab.nb.digits=4)+
stat_compare_means(label = "p.signif",
label.x=1.5,label.y=0.18,
method = "t.test",paired = TRUE)
1.png
#speed效应
ggline(data2,x="speed",y="lapse",add=c("mean_se"))
2.png
#time*speed交互作用
ggline(data2,x="speed",y="lapse",color="time",add=c("mean_se"))
3.png
#meanrt
#time效应可视化
ggline(data3,x="time",y="meanrt",add=c("mean_se"))+
stat_compare_means(label = "p.signif",
label.x=1.5,label.y=0.18,
method = "t.test",paired = TRUE)
#speed效应
ggline(data3,x="speed",y="meanrt",add=c("mean_se"))
#time*speed交互作用
ggline(data3,x="speed",y="meanrt",color="time",add=c("mean_se"))
#corate
#corate_t
ggline(data3,x="time",y="corate",add=c("mean_se"))+
stat_compare_means(label = "p.signif",
label.x=1.5,label.y=0.85,
method = "t.test",paired = TRUE)
#corate_s
compare_means(corate~speed,data=data3,paired = T)
compare_means(corate~speed,data=data3,method = "anova")
compare_means(corate~speed,data=data3,method = "kruskal.test")
my_compar=list(c("1","3"),c("1","4"),c("2","3"),c("2","4"),c("3","4"))
p=ggline(data3,x="speed",y="corate",palette="lancet",width = 0.5,
add=c("mean_se"))
p+stat_compare_means(comparisons = my_compar,label = "p.signif",label.y = c(0.85,0.9,0.95,1.0,1.05))+
stat_compare_means(label.x = 1.6,label.y=1.15)
#time*speed交互作用
ggline(data3,x="speed",y="corate",color="time",add=c("mean_se"))
网友评论