library(foreign)
study5 <- read.spss("reanalysis-study-5-mt-fall-08.sav", to.data.frame=TRUE)
ASData5 <- subset(study5, select=c("ppnum", paste("as", 1:33, sep="")))
prepareMplusData(ASData5, "study5.dat")
# basic example
test01 <- prepareMplusData(mtcars, "test01.dat")
# see that syntax was stored
test01
# tests for keeping and dropping variables
prepareMplusData(mtcars, "test02.dat", keepCols = c("mpg", "hp"))
prepareMplusData(mtcars, "test03.dat", keepCols = c(1, 2))
prepareMplusData(mtcars, "test04.dat",
keepCols = c(TRUE, FALSE, FALSE, TRUE, FALSE,
FALSE, FALSE, FALSE, FALSE, FALSE, FALSE))
prepareMplusData(mtcars, "test05.dat", dropCols = c("mpg", "hp"))
prepareMplusData(mtcars, "test06.dat", dropCols = c(1, 2))
prepareMplusData(mtcars, "test07.dat",
dropCols = c(TRUE, FALSE, FALSE, TRUE, FALSE,
FALSE, FALSE, FALSE, FALSE, FALSE, FALSE))
# interactive (test08.dat)
prepareMplusData(mtcars, interactive=TRUE)
# write syntax to input file, not stdout
prepareMplusData(mtcars, "test09.dat", inpfile=TRUE)
# write syntax to alternate input file, not stdout
prepareMplusData(mtcars, "test10.dat", inpfile="test10alt.inp")
# should be error, no file
prepareMplusData(mtcars, interactive=FALSE)
# new warnings if it is going to overwrite files
# (the default to be consistent with prior behavior)
prepareMplusData(mtcars, "test10.dat")
# new warnings if it is going to overwrite files
# (the default to be consistent with prior behavior)
prepareMplusData(mtcars, "test11.dat", inpfile="test10alt.inp")
# new errors if files exist and overwrite=FALSE
prepareMplusData(mtcars, "test10.dat",
inpfile="test10alt.inp", overwrite=FALSE)
Run the code above in your browser using DataLab