Learn R Programming

R2MLwiN (version 0.1-7)

ws2foreign: Converts data from one format to another within MLwiN

Description

This function converts data from one format to another within MLwiN, via MLwiN macro language. The foreign package allows R to read data files for most of these formats.

Usage

ws2foreign(wsfile, foreignfile, MLwiNPath, x64=FALSE)

Arguments

wsfile
A file name specifying the data file (with a specific extension) to be converted.
foreignfile
A file name specifying the data file (with a specific extension) after conversion.
MLwiNPath
A path to the MLwiN folder. By default, MLwiNPath = "C:/Program Files (x86)/MLwiN v2.27/".
x64
A logical value indicating whether the 64 bit version of MLwiN is used. If FALSE (by default), the 32 bit version is called.

Value

  • The converted data file (with a specific extension) will be saved in a given folder.

Details

MLwiN supports conversion between MLwiN (*.wsz, *.ws), Minitab (*.mtw), SAS (*.xpt), SPSS (*.sav), and Stata (*.dta) files.

See Also

read.dta

Examples

Run this code
## Modify the following paths as appropriate.
## MLwiN folder
mlwin = "C:/Program Files (x86)/MLwiN v2.27/"
## MLwiN sample worksheet folder
wsfile=paste(mlwin,"/samples/tutorial.ws",sep="")
## the tutorial.dta will be save under the temporary folder
inputfile=paste(tempdir(),"/tutorial.dta",sep="")
ws2foreign(wsfile, foreignfile=inputfile, MLwiNPath=mlwin)
library(foreign)
indata =read.dta(inputfile)

Run the code above in your browser using DataLab