ws2foreign {R2MLwiN}R Documentation

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 = NULL, x64 = NULL)

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 = NULL and path set by options('MLwiN_path'), the default for which can be changed via options(MLwiN_path = 'path/to/MLwiN vX.XX/')).

x64

A logical value indicating whether the 64 bit version of MLwiN is used, the default for this is determined by the version of R used. If FALSE, the 32 bit version is called.

Details

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

The converted data file (with a specific extension) will be saved to the file specified by foreignfile.

Author(s)

Zhang, Z., Charlton, C.M.J., Parker, R.M.A., Leckie, G., and Browne, W.J. (2016) Centre for Multilevel Modelling, University of Bristol.

See Also

read.dta

Examples


## Not run: 
library(R2MLwiN)
# NOTE: if MLwiN not saved in location R2MLwiN defaults to, specify path via:
# options(MLwiN_path = 'path/to/MLwiN vX.XX/')
# If using R2MLwiN via WINE, the path may look like this:
# options(MLwiN_path = '/home/USERNAME/.wine/drive_c/Program Files (x86)/MLwiN vX.XX/')

wsfile = normalizePath(file.path(getOption("MLwiN_path"), "samples/tutorial.ws"), winslash = "/")
## the tutorial.dta file will be saved in the temporary folder
inputfile = normalizePath(file.path(tempdir(), "tutorial.dta"), winslash = "/", mustWork = FALSE)
ws2foreign(wsfile, foreignfile = inputfile)
library(foreign)
indata = read.dta(inputfile)
str(indata)
unlink(inputfile)

## End(Not run)


[Package R2MLwiN version 0.8-9 Index]