R is a free, open-source environment for statistical computing and graphics.  Stat/Transfer will read and write workspace files for R versions 2 and 3.


Standard extension:  rdata


Reading R files

The R file format is very unstructured and allows the user to write almost anything  into it. Therefore Stat/Transfer imposes a few restrictions on input files.  Specifically, your data file should contain at least one of the following kinds of objects.


  •       two dimensional matrices

  •       vectors

  •       factors

  •       dataframes

  •       tables


Stat/Transfer can read R files in either binary or ASCII format.  Compressed files are  supported, as is the newer Version 3 serialization format.


Writing R files

On output, Stat/Transfer writes an R dataframe.  If your input data set does not have a variable named 'rownames', Stat/Transfer will create an extra variable containing the case number, stored as an integer variable and named 'rownames'.


Factors in R consist of a vector of zero-based numeric values and a vector of string labels that are mapped onto the values.  You can choose to have these written to an output file as the numeric values and their value labels or you can write them as strings.  This option is controlled in the R and S-Plus Options section of the Options dialog box.   If you are going to a package such a Stata or SPSS, that supports value labels, the first option is more appropriate.


Stat/Transfer will writes R data in any of three formats.  1) The ASCII format, which is compatible across platforms, but now regarded as obsolete. 2) Version 2 compressed binary files, and 3) Version 3 compressed, binary utf-8 workspace files.

Time Values in R
R stores dates in POSIX format, which includes information on the time zone.  Because of this, Stat/Transfer cannot detect the time zone. Therefore, we indicate to R that the dates are in GMT. Unfortunately R defaults to displaying dates using the local time zone. You can work around this with the following R command:




This will cause R will display the dates exactly as they were displayed in your original file.


Missing Data

R supports missing values.  On input, missing values are converted to the internal missing value in Stat/Transfer.  On output, missing values are converted to the value appropriate for each variable type.


If you are using Version One of R, check the Write version one string missing option in the R and S-Plus Options section of the Options dialog box and the appropriate value will be written for null or missing strings. If you are using a later version of R, leave this unchecked.




Output Variable Types

The output variable type that results from each target variable type is given in the following table:




Target Type

Output Type





















POSIX timestamp (note the time zone is not set, so the time will be in GMT)