similar to: Recoding Variables in R

Displaying 20 results from an estimated 4000 matches similar to: "Recoding Variables in R"

2010 Feb 03
1
Changing an unordered factor into an ordered factor
I'm trying to change an unordered factor into an ordered factor: data96$RV961327 <- data96$V961327 data96$RV961327[data96$V961327 %in% levels(data96$V961327)[4]] <- NA data96$RV961327[data96$V961327 %in% levels(data96$V961327)[5]] <- NA data96$RV961327 <- factor(data96$RV961327) attributes(data96$RV961327) levels(data96$RV961327) data96$RV961327 data96$RRV961327 <-
2010 Jan 31
1
Running a Logit Model in R
I'm an R newbie and had the following question. I'm trying to run a logit model because I have a dependant variable that is a factor with three levels. Each of my independent variables are factor variables and have two or more levels, which is why I'm unsure about the error. regone <- glm(data96$RV961327 ~ data96$RV960605 + data96$RV960610 + data96$RV960337 + data96$RV960385 +
2010 Mar 29
1
Question about 'logit' and 'mlogit' in Zelig
I'm running a multinomial logit in R using the Zelig packages. According to str(trade962a), my dependent variable is a factor with three levels. When I run the multinomial logit I get an error message. However, when I run 'model=logit' it works fine. any ideas on whats wrong? ## MULTINOMIAL LOGIT anes96two <- zelig(trade962a ~ age962 + education962 + personal962 + economy962 +
2010 Apr 07
2
recoding variables-recode not working
Hi, I have numerical variable that I want to recode into categories '0' and '1 and more' and do analysis with that data. I have tried various of possibilities to do so, but I am sucked and nothing is working. recode(Q12, "0='A';1:30='B'") cut(Q12, breaks=c(0,1,30), lables=c('0', '1 and more')) cat(Q12, "0=0;1-33=1") What should
2011 Feb 13
2
Recoding using the memisc package
Dear All, I am trying to recode a variable using the functions provided by "memisc" package. Actually I am following the examples on page 9-10 of the vignette: -------------------------------------------------------------------------- d.fig <- within(d.fig,{ sev <- recode(sev, 1 -> 0.9, 2 -> 1.0, 3 -> 1.1, 4 ->
2010 Jul 23
1
FW: recoding problem
Hi, I am trying to recode the output from a matrix(here is a small snippet of it): HGlt10RawPerc2008[1:20] [1] -5 0 -1 -1 0 2 3 -5 -2 0 2 0 1 -2 3 0 4 1 4 2 Here is the code I am using to recode it: HGBlt10Points2008 = recode(HGlt10RawPerc
2005 Aug 23
1
Seeking help with an apparently simple recoding problem
Hello, I have struggled, for longer than I care to admit, with this seemingly simple problem, but I cannot find a solution other than the use of long drawn out ifelse statements. I know there has to be a better way. Here is stripped down version of the situation: I start with: a <- c(1,0,1,0,0,0,0) b <- c(1,1,1,1,0,0,0) c <- c(1,1,0,1,0,0,0) rbind(a,b,c) [,1] [,2] [,3] [,4] [,5]
2011 Feb 18
3
recoding a data in different way: please help
Dear R users The following question looks simple but I have spend alot of time to solve it. I would highly appeciate your help. I have following dataset from family dataset : Here we have individuals and their two parents and their marker scores (marker1, marker2,....and so on). 0 means that their parent information not available. Individual Parent1 Parent2 mark1 mark2 1 0 0
2004 Jul 03
3
Recoding scores of negatively worded item
Hi, 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 <-
2008 May 19
2
recoding data with loops
# I'm new to R and am trying to get the hang of how it handles # dataframes & loops. If anyone can help me with some simple tasks, # I'd be much obliged. # First, i'd like to generate some random data in a dataframe # to efficiently illustrate what I'm up to. # let's say I have six variables as listed below (I really # have hundreds, but a few will illustrate the point). #
2007 Jun 11
1
Recoding
I want to do some recoding of variables: code Age into groups and recode a factor into a smaller number of levels. There are a couple of options for recode functions, in the car package and in memisc, and I think in gmisc. Does anyone have any opinions on the the easiest, most reliable approach for these problems? David Scott _________________________________________________________________
2008 Jun 27
4
Recoding
Hi! Given a vector (or a factor within a df),i.e. v1 <- c(1,1,1,2,3,4,1,10,3) and a dictionary cbind(c(1,2,3),c(1001,1002,1003)) is there a function (on the same line than recode() in car) to get v2 as c(1001,1001,1001,1002,1003,4,1001,10,1003) ? I'm using myself a function based on match() since long ago (I think that thanks to advice by Prof. B. Ripley), but would like to know if there
2004 Oct 18
2
Recoding factors
I'm having a bit of trouble recoding factors in a fields. I have a field which has the factors Singleton, Twin and Triplet. I want to recode the field to have only the factors Singleton and Multiple. Any advice? Cheers, Neil
2004 Mar 11
5
recoding variables
Hi, I was hoping someone could help me. I am a graduate student new to using R, and I'm trying to figure out how to recode a continuous variable to make it into an ordinal variable with 3 categories. I literally have no idea how to proceed--could anyone possibly advise me? Please copy me on any responses, as I have just subscribed to the R-help email list but don't know whether the
2011 Feb 19
1
Conditional recoding
I am trying to recode a variable into another variable and while the package 'car' works well when it is only recoding A into B, I am not sure I can do the same with recoding (A or C) into B. If i can use recode please advise on how to. So i am using an if/else if conditions. My sample dataset is below along with the code and the warning and results i get. TIA Krishnan #****Code****
2012 May 18
2
Recoding numeric value
I am a newbie and can't figure out how to recode a numeric value. In my data (pharm311), I have a column called "explain" and I need to find all the 6's and change it to NA (blank). Could someone help? I'm sorry if this is too basic, I started messing with R this week and got stuck with this problem since yesterday... Thanks in advance!
2009 Jul 01
2
recoding charactor variables with special charactors
I have a several character variables that I need to recode, but some of them have special characters like single quote or ( ). How tell R to ignore these special characters so I can rename them? Below is the error message I am getting. social$FamilySupport[social$FamilySupport=="Mr. XXXs' extended family live in the Nashville area where he and his wife reside."]<-"Highly
2008 Jul 03
3
Recoding a variable
Hi All, I'm relatively new to R. I have a variable, "internet use," which ranges from "Almost everyday, "Several times a week," "Several times a month," "Seldom," "Never," and "Don't know." I want to recode this data into a new variable, say "use.internet," such that I have a dichotomous variable indicating
2010 Jun 26
2
Recoding dates to session id in a longitudinal dataset
Hi, I'm fairly new to R but I have a large dataset (300000 obs) containing patient material. Some patients came 2-9 times during the three year observation period. The patients are identified by a unique idnr, the sessions can be distinguished using the session date. How can I recode the date of the session to a session id (1-9). This would be necessary to obtain information and do some
2011 Sep 01
2
Automatic Recoding
I have a text file full of numbers (it's a edgelist for a graph) and I would like to recode the numbers as they are way too big to work with. So for instance the following: 676529098667 1000198767829 676529098667 100867672856227 676529098667 91098726278 676529098667 98928373 1092837363526 716172829 would become: 0 1 0 2 0 3 0 4 5 6 i.e. all 676529098667 would become