simsem / semTools

Useful tools for structural equation modeling
75 stars 36 forks source link

Save file as csv? #21

Closed ckraner closed 7 years ago

ckraner commented 7 years ago

It would be very convenient to be able to use savefile() and have it output a comma-delimited file, or even a tab-delimited file. I want to use this to import tables into LaTeX, as well as eventually display this table in the R-Studio viewer, and this would make things much easier.

Love the package!

TDJorgensen commented 7 years ago

Thanks, and good idea. You could already save as tab-delimited file using the argument tableFormat = TRUE, but I just added a writeArgs argument so you can pass more arguments to write.table(). Following from the examples on the help page, try this:

saveFile(fit, "out.txt", "mifit", tableFormat = TRUE)

If you install the latest development version of semTools (0.4-15.907), you can try the CSV option.

devtools::install_github("simsem/semTools/semTools")
saveFile(fit, "out.csv", "mifit", tableFormat = TRUE, writeArgs = list(sep = ","))

You should be able to open "out.csv" in Excel or LibreOffice-Calc and see a nicely delimited table.