nret.translator {klausuR} | R Documentation |
Convert NRET/ET data between klausuR and other software
Description
This function should help to interchange answer data between R and other statistical software packages – especially SPSS, but it's probably useful for other products as well.
Usage
nret.translator(
dat,
items = NULL,
spss = "out",
corr = FALSE,
num.alt = NULL,
klausuR.alt = c(is.true = "+", is.false = "-", missing = "0", err = "*"),
spss.alt = c(is.true = "2", is.false = "1", missing = "0", err = "3"),
rm.old.vars = TRUE,
items.only = FALSE,
klausuR.prefix = c(),
spss.prefix = c()
)
Arguments
dat |
A data.frame, the object to convert. |
items |
Optional vector defining the columns to convert. If |
spss |
Either "in" or "out", depending on the direction of conversion. |
corr |
Logical. Set to |
num.alt |
A numeric value definig the number of answer alternatives for each item. Can be a vector, if items have different numbers of options. If it is shorter than the number of items, it will be repeated for all items. |
klausuR.alt |
A named vector defining the codes for |
spss.alt |
A named vector defining the codes for SPSS type of answers. |
rm.old.vars |
Logical. If |
items.only |
Logical. If |
klausuR.prefix |
A named character vector with two optional elements,
|
spss.prefix |
Like |
Details
klausur
expects data in a special format if it should be evaluated according to (Number Right) Elimination
Testing (NRET/ET),
only one variable per item. Other software products might not be able to process this rather
condensed format. In that case, you will most likely need several variables for each item,
i.e. one per answer alternative.
Adding to that, the coding of answers is by default done with "+", "-",
"0" and "*" in klausuR
, again a
solution that might confuse other products.
This function translates data in both directions,
and does also convert vectors giving the correct answer. The latter
will turn a klausuR
type answer string into a number indicating the correct alternative (and the other way round).
This means that it will only work if there's exactly one valid answer to each item. If you convert towards SPSS,
the resulting list will also include SPSS syntax to define variables respectively.
Value
If corr=FALSE
,
a data.frame with more or less columns (depending on rm.old.vars
and items.only
).
If corr=TRUE
,
returns a named vector if spss="in"
and a list if spss="out"
(containing SPSS syntax
in the element syntax
and also a named vector, called answ
).
Note
The conversion is done on an object basis, that is,
nret.translator
will not open or write files,
but take and return R objects. The function should ignore any other columns/variables in the object.
Author(s)
m.eik michalke meik.michalke@uni-duesseldorf.de
See Also
Examples
## Not run:
# from SPSS to R
data(spss.data)
klausuR.data <- nret.translator(spss.data, spss="in")
spss.corr <- c(
item01=2, item02=3, item03=3, item04=3, item05=2,
item06=2, item07=3, item08=1, item09=1, item10=2)
klausuR.corr <- nret.translator(spss.corr, spss="in", corr=TRUE, num.alt=3)
# from R to SPSS
spss.data <- nret.translator(klausuR.data)
spss.corr <- nret.translator(klausuR.corr, corr=TRUE, num.alt=3)
# if you find the syntax useful
cat(spss.corr$syntax, file="~/somewhere/NRET.sps")
## End(Not run)