Skip to content

Commit

Permalink
rmaov2_car.R: fix for problem when factors organized in unexpected way
Browse files Browse the repository at this point in the history
  • Loading branch information
mortonne committed Jun 15, 2014
1 parent dd63be7 commit 2326bab
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion stats/rmaov2_car.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,17 @@ data <- read.table(args[1], colClasses=c('numeric', rep('factor', 3)),

n <- length(levels(data$subject))
conds <- length(data$dep) / n
data$time <- rep(seq(1, conds), each=n)

l1 <- levels(data$V1)
l2 <- levels(data$V2)
k <- 1
data$time = vector('numeric', length(data$dep))
for (i in 1:length(l1)) {
for (j in 1:length(l2)) {
data$time[data$V1 == l1[i] & data$V2 == l2[j]] = k
k = k + 1
}
}

# reshape to wide format
wide <- reshape(data, v.names='dep', timevar='time', idvar='subject', direction='wide', drop=c('V1','V2'))
Expand Down

0 comments on commit 2326bab

Please sign in to comment.