ez.reads2 | R Documentation |
ez.reads: haven, usrna always to NA, col width >255 characters OK, Date, Time -> Date, hms/difftime
ez.reads2: foreign, perserve initial usrna if necessary, col width >255 characters Bad, Date, Time -> numeric.
internally trim (leading and trailing) string spaces (The leading could be previously added by user, the trailing could come from SPSS padding to Width).
SPSS numeric -> R numeric
SPSS string (could be string of num) -> R character...then, when stringsAsFactors=T... -> R factor.
SPSS Type (numeric, string) matters, but Measure (scale, ordinal, nominal) seems to not matter
See param for more other details.
Also somehow auto replace irregular chars in the col names (eg, @–>.)
ez.reads2(
file,
atm2fac = 2,
usrna = TRUE,
tolower = FALSE,
stringsAsFactors = FALSE,
blanksAsNA = TRUE,
na.strings = c("", "."),
makenames = TRUE,
...
)
atm2fac |
c(1,2,3). atomic means logic,numeric/double,integer,character/string etc. Char to factor controlled separately by stringsAsFactors.
|
usrna |
if TRUE, honor/convert user-defined missing values in SPSS to NA after reading into R; if FALSE, keep user-defined missing values in SPSS as their original codes after reading into R. Should generally be TRUE, because most R stuff does not auto recognize attr well. |
tolower |
whether to convert all column names to lower case |
stringsAsFactors |
T/F |
blanksAsNA |
T/F, converts factor or character vector elements to NA if matching na.strings |
na.strings |
only applicable if blanksAsNA=T. e.g., c(”,'.','NA','na','N/A','n/a','NaN','nan') |
makenames |
not effective for this function, kept for compatiablity with other functions |
As of Nov, 2017, haven package eariler version is somewhat buggy, less powerful, but has been evolving a lot. I am not going to update haven right now. So stick with foreign. Potentially, one can also use SPSS R plugin to pass data between SPSS and R. see the "extra-variable" bug https://stackoverflow.com/a/7724879/2292993
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.