# The raw data: # DF = data.frame( student=as.factor( 1:15 ), waking=c( 18, 19, 16, 21, 16, 20, 20, 14, 11, 22, 19, 29, 16, 27, 15 ), hypnotic=c( 25, 20, 26, 26, 20, 23, 14, 18, 18, 20, 22, 27, 19, 27, 21 ) ) # Convert this dataframe into a form that the R aov command can directly use: # if( FALSE ){ # # "by hand" # block=c( DF$student, DF$student ) measurement=c( DF$waking, DF$hypnotic ) type=c( rep( 0, length(DF$waking) ), rep( 1, length(DF$hypnotic) ) ) DF_melt = data.frame( measurement=measurement, block=block, type=type ) }else{ # # Using melt. # library(reshape2) DF_melt = melt(DF, id.vars=c('student'), value.name='n_correct', variable.name='state') }