File: write.foreign.Rd

package info (click to toggle)
foreign 0.8.61-1
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 1,560 kB
  • ctags: 863
  • sloc: ansic: 7,501; asm: 4; makefile: 1
file content (61 lines) | stat: -rw-r--r-- 2,024 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
% This file is part of the 'foreign' package for R
% It is distributed under the GPL version 2 or later

\name{write.foreign}
\alias{write.foreign}
\title{Write Text Files and Code to Read Them}
\description{
This function exports simple 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", "SAS"), ...)
}
\arguments{
  \item{df}{A data frame}
  \item{datafile}{Name of file for data output}
  \item{codefile}{Name of file for code output}
  \item{package}{Name of package}
  \item{\dots}{Other arguments for the individual \code{writeForeign}
    functions}
}
\details{
The work for this function is done by
\code{foreign:::writeForeignStata}, \code{foreign:::writeForeignSAS} and
\code{foreign:::writeForeignSPSS}.  To add support for another package,
eg Systat, create a function \code{writeForeignSystat} with the same first
three arguments as \code{write.foreign}. This will be called from
\code{write.foreign} when \code{package="Systat"}.

Numeric variables and factors are supported for all packages: dates and
times (\code{Date}, \code{dates}, \code{date}, and \code{POSIXt}
classes) and logical vectors are also supported for SAS and characters
are supported for SPSS.

For \code{package="SAS"} there are optional arguments
\code{dataname = "rdata"} taking a string that will be the SAS data set
name, \code{validvarname} taking either \code{"V6"} or \code{"V7"},
and \code{libpath = NULL} taking a string that will be the directory where
the target SAS datset will be written when the generated SAS code been
run.
}
\value{
  Invisible \code{NULL}.
}

\author{
  Thomas Lumley and Stephen Weigand
}
\examples{\dontrun{
datafile<-tempfile()
codefile<-tempfile()
write.foreign(esoph,datafile,codefile,package="SPSS")
file.show(datafile)
file.show(codefile)
unlink(datafile)
unlink(codefile)
}}
\keyword{file}