我有一个包含多个列的csv,
user_id,question_id,level,epoch和correct
它包含问题的答案,我想使用纪元时间计算每个问题答案的时间。我创建了一个计算每个问题的时间的脚本,但是我希望将数据的时间汇总到数据中的答案行
# Load file
data <- read.csv(file="D:/data.csv",head=TRUE,sep=";")
diff <- function(v) {
return((v[2:length(v)] - v[1:length(v)-1]))
}
diffmean <- function(v) {
return(mean(v[2:length(v)] - v[1:length(v)-1]))
}
#Time per answer and user
answerTime <- aggregate(data[,c("epoch")],
list(user_id = data$user_id),
diff)
# Average response time
meanTimePerUser <- aggregate(data[,c("epoch")],
list(user_id = data$user_id),
diffmean)