write.foreign {foreign}R Documentation

Write text files and code to read them.

Description

This function exports data frames to other statistical packages by writing the data as free-format text and writing a separate file of instructions for the other package to read the data.

Usage

write.foreign(df, datafile, codefile, package = c("SPSS","Stata"), ...)

Arguments

df A data frame
datafile Name of file for data output
codefile Name of file for code output
package Name of package
... Other arguments for the individual writeForeign functions

Details

The work for this function is done by foreign:::writeForeignStata and foreign:::writeForeignSPSS. To add support for another package, eg SAS, create a function writeForeignSAS with the same first three arguments as write.foreign. This will be called from write.foreign when package="SAS".

Value

None

Author(s)

Thomas Lumley

Examples

## Not run: 
datafile<-tempfile()
codefile<-tempfile()
write.foreign(esoph,datafile,codefile,package="SPSS")
file.show(datafile)
file.show(codefile)
unlink(datafile)
unlink(codefile)
## End(Not run)

[Package foreign version 0.8-6 Index]