library(reshape2)
#Code below melts four columns from a wide data set into four in a long data set
#ID and Gender appear on both lines for each participant (that's why they are id.vars)
#A "variable" column denotes whether the variable is pretest (ScCurrentEv1) or posttest (ScCurrentEv2)
#A "value" column includes the value of the DV at each occasion
## Loading required package: lattice
## Loading required package: survival
## Loading required package: Formula
## 
## Attaching package: 'Hmisc'
## The following objects are masked from 'package:base':
##
## format.pval, units
currlong <- melt(Wk07[,c("ID","Gender","ScCurrentEv1","ScCurrentEv2")], 
id.vars=c("ID","Gender"))

#Bonus: How to then plot that two occasion data set:
library(Hmisc)
library(ggplot2)
ggplot(currlong, aes(x=variable, y=value, colour=Gender,
group=Gender)) +
stat_summary(fun = mean,
geom = "point") +
stat_summary(fun.data = mean_cl_normal,
geom = "errorbar",width=0.2, fun.args=list(mult=1.96),size=1) +
geom_smooth(method='lm', formula= y~x, size=1,se=FALSE)+
labs(title = "Prepost current event change in men and women",
x= "Occasion (Pretest, Posttest)",
y="Current Event Knowledge (scale score)") +
theme_bw() +
theme(text=element_text(size=10))