I have multiple .csv files with names "sub block#":
01 block1 01 block2 01 block3 02 block1 02 block2 02 block3
I would like to
- get the mean for each participant grouped by "cue" (my current code tries get the mean for each file, but not for each subject)
- save the output to one .csv file
files <- list.files(path="C:/Users/", pattern="*.csv", full.names=TRUE,
recursive=FALSE)
for (file in files ){
data<-read.csv(file)
summarize.stat<-
data%>%
group_by(Cue) %>% # grouping stats
drop_na() %>%
summarize(count=n(),
mean.RT= mean(RT))
write.csv(summarize.stat, paste("C:/Users/",'RTcue,csv',sep = ""),
row.names = FALSE, quote = FALSE)
}
This is what shows in the Console
summarise()
ungrouping output (override with .groups
argument)
summarise()
ungrouping output (override with .groups
argument)
summarise()
ungrouping output (override with .groups
argument)
summarise()
ungrouping output (override with .groups
argument)
summarise()
ungrouping output (override with .groups
argument)
summarise()
ungrouping output (override with .groups
argument)
**
Error: Problem with summarise()
input mean.RT
.
x error in evaluating the argument 'x' in selecting a method for function 'mean': object 'RT' not found**
i Input mean.RT
is mean(RT)
.
i The error occurred in group 1: Cue = "Center".
So my questions are: 1.How to fix the error? 2.and how to get the mean by each subject?
Thank you for any advice! I've struggled with it for quite a while.