Solution: Stata's spagplot errorneously plots vertical lines

Stata's spagplot fails and plots vertical lines, but there is an easy solution in R.

library(foreign)
data <- read.dta("C:/Users/hellmund/Documents/MyStataDataFile.dta")
names(data)
levels(data$group)
#First column contains initial measurements, k'th column measurements at time k
dataLong <- reshape(data, direction="long", varying=list(names(data)[1:10]), v.names=NULL,idvar=c("id"), timevar="Visit", times=1:10)
png(file="C:/Users/hellmund/Documents/spagplot.png", bg="transparent")
interaction.plot(dataLong$Visit,dataLong$id, dataLong$Size xlab="Visit", ylab="Size(mm)", legend=F,lty=1, ylim=c(30,70))
#Critical cut-off value is marked with a horizontal line
abline(h=55)
dev.off()

Comments

Popular Posts