[OGRUG] R-UG-Ottawa Digest, Vol 5, Issue 2

Prof. John C Nash nashjc at uottawa.ca
Sat Sep 19 14:37:15 CEST 2009


Mark,

You would do better on R-help list. This one is mainly for announcing 
local Ottawa area activities related to R.

However, when dealing with Excel files, I usually first get them into an 
R dataframe (read.table or read.csv, though there are some xls 
functions). Then I'd write a small script to create the new variable 
from the old (so I could reuse it later), containing something like

mydata$newcode<-8-mydata$oldcode

You may want to think of

mydata$newcode<-as.factor(8-mydata$oldcode)

depending on the use for the code.

JN



r-ug-ottawa-request at r-project.org wrote:
> Send R-UG-Ottawa mailing list submissions to
> 	r-ug-ottawa at r-project.org
> 
> To subscribe or unsubscribe via the World Wide Web, visit
> 	https://stat.ethz.ch/mailman/listinfo/r-ug-ottawa
> or, via email, send a message with subject or body 'help' to
> 	r-ug-ottawa-request at r-project.org
> 
> You can reach the person managing the list at
> 	r-ug-ottawa-owner at r-project.org
> 
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of R-UG-Ottawa digest..."
> 
> 
> Today's Topics:
> 
>    1. Requesting help with recoding variables (Mark Podolsky)
> 
> 
> ----------------------------------------------------------------------
> 
> Message: 1
> Date: Fri, 18 Sep 2009 10:56:29 -0400
> From: Mark Podolsky <podolsmg at mcmaster.ca>
> Subject: [OGRUG] Requesting help with recoding variables
> To: r-ug-ottawa at r-project.org
> Message-ID: <8FA920D2-28E0-482F-9A11-3DFD3750BDEC at mcmaster.ca>
> Content-Type: text/plain
> 
> Hi - I am new to R, and am becoming increasingly comfortable with  
> performing my analyses in R, but I am struggling a bit with  
> manipulating my data.  I found this list on the CRAN website, and I  
> hope that this post is in line with the purpose of the list.
> 
> I have a data set in Excel that I move to the R environment, but I am  
> stuck figuring out how to transform the items that must be reverse  
> coded.  Specifically, I have a number of items that are on a scale  
> from 1-8; I need to reverse all the numbers between 1 and 7, and  
> recode 8 as 0 (i.e. 7-to-1, 1-to-7, 6-to-2, 2-to-6,etc. and 8-to-0).
> 
> I would really appreciate some assistance in performing this action.
> 
> Thanks all!
> 
> Mark Podolsky
> PhD Candidate
> Human Resources and Organizational Behaviour
> DeGroote School of Business
> McMaster University
> podolsmg at mcmaster.ca
> 
> 
> 
> 
> 	[[alternative HTML version deleted]]
> 
> 
> 
> ------------------------------
> 
> _______________________________________________
> R-UG-Ottawa mailing list
> R-UG-Ottawa at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-ug-ottawa
> 
> 
> End of R-UG-Ottawa Digest, Vol 5, Issue 2
> *****************************************



More information about the R-UG-Ottawa mailing list