【发布时间】:2018-10-08 18:58:42
【问题描述】:
当我尝试运行此代码时,会出现标题中的错误。我是初学者,不明白如何解决它。我已包含所有代码以供参考。 ggplot 行之前的所有行似乎都有效,但最后一行会导致错误。
ClassStroopData_300 <- read_csv("ClassStroopData_300.csv")
Data300 <-ClassStroopData_300
mean(Data300$responseTime)
sd(Data300$responseTime)
Data300["WorkspaceVar1"] <- grepl("_",Data300$note)
WorkspaceVar1 that contains the info whether or not the column "note" contained a "_"
Data300["WorkspaceVar2"] <- grepl("text",Data300$content)
Data300["WorkspaceVar3"] <-grepl("red_red|blue_blue|green_green|orange_orange|purple_purple",Data300$content)
Data300["WorkspaceVar4"] <- grepl("4db78970c3816d3d|a8cc6a79046e188f|c21c48d74bc99a6|dd2942c485109f3e|5eb0fbeb9b0685e2",Data300$frameId)
Data300["incongruent"] <- Data300$WorkspaceVar1*2
Data300["instructions"] <- Data300$WorkspaceVar2*1
Data300["congruent"] <- Data300$WorkspaceVar3*3
Data300["practice"] <- Data300$WorkspaceVar4*10
Data300["condition sums"] <- Data300$incongruent + Data300$instructions + Data300$congruent + Data300$practice
Data300["condition"] <- factor(Data300$`condition sums`,levels = c("1","2","3","12"),labels = c("instructions","incongruent","congruent","practice"))
CongruentTrials <- subset(Data300, condition == "congruent")
mean(CongruentTrials$responseTime)
sd(CongruentTrials$responseTime)
IncongruentTrials <- subset(Data300, condition == "incongruent")
mean(IncongruentTrials$responseTime)
sd(IncongruentTrials$responseTime)
aggregate(Data300$responseTime,list(Data300$condition),mean)
aggregate(Data300$responseTime,list(Data300$condition),sd)
MICT <- mean(IncongruentTrials$responseTime)
SDICT <- sd(IncongruentTrials$responseTime)
MCT <- mean(CongruentTrials$responseTime)
SDCT <- sd(CongruentTrials$responseTime)
cbind(c(MICT,MCT), c(SDICT,SDCT))
table = cbind(c(MICT,MCT), c(SDICT,SDCT))
colnames(table) = c("mean","standard deviation")
rownames(table) = c("Incongruent", "Congruent")
t.test(IncongruentTrials$responseTime, CongruentTrials$responseTime, paired = T, var.equal = T)
library(ggplot2)
IncongruentNoOutliers <- subset(IncongruentTrials, responseTime < 1267.0660+401.6672*3.5 & responseTime > 1267.0660-401.6672*3.5)
CongruentNoOutliers <- subset(CongruentTrials, responseTime < 1009.4660+352.9656*3.5 & responseTime > 1009.4660-352.9656*3.5)
CongruentNoOutliers$Identify = "Congruent"
IncongruentNoOutliers$Identify = "Incongruent"
AllNoOutliers = rbind(CongruentNoOutliers, IncongruentNoOutliers)
ggplot(AllNoOutliers, aes(x=responseTime, fill=as.factor(identify))) + geom_histogram(alpha = 0.5, position = 'identity') + scale_fill_discrete(name="Trial Type")
【问题讨论】:
-
您应该能够添加比这更多的代码,除非您超过了问题的最大字符限制(在这种情况下,您应该将问题的范围缩小到合身)。您可以再试一次,但在代码前添加一些常规文本。