[R] Recoding scores of negatively worded item
a.prioglio at city.ac.uk
Sat Jul 3 17:45:26 CEST 2004
I'm new to R so please fogive if I write someting silly ...
I need to recode a series of responses from a number of questionnaires.
The data is read via ODBC from a database where all responses are coded
as tables of the form (id, question, score).
After dealing with recoding of missing values, I need to "invert" the
scores of some questionnaire's item in the form x <- (n - x) where n is
the range of allowed responses + 1, e.g. if score can range from 1 to 4
n would by 5.
I am using R version 1.9.1 and 1.8.1 with identical outcome.
If from the R interpreter I write
ces[is.element(ces$question,c(1,3,5),]$score <- 5 -
the system correctly recode the scores for questions 1,3,5 on the table
If the same expression is processed as part of a script I get a "syntax
My question is a) is this the best way to recode scores? (I did look at
the package car but I did not see how to perform a conditional recoding,
nor was obvious how to to operations on scores)
b) why there is a different behavior from the command line and from a
c) how to solve the problem? (As the amount of data is large I need to
do everything via scripts)
Thank you for your attention.
We are what we repeatedly do. Excellence, then, is not an act, but a habit.
\ / ASCII RIBBON CAMPAIGN - AGAINST HTML MAIL
X - AGAINST MS ATTACHMENTS
More information about the R-help