search for: recoded

Displaying 20 results from an estimated 700 matches for "recoded".

Did you mean: decoded
2009 Apr 01
4
Recode of text variables
Hi all I am trying to do a simple recode which I am stumbling on. I figure there must be any easy way but haven't come across it. Given data of A","B","C","D","E","A" it would be nice to recode this into say three categories ie A and B becomes "Treat1", C becomes "Treat 2" and E becomes "Treat 3". I tried
2012 Nov 09
5
using lapply with recode
...nd "Data Manipulation With R" (Spector). I have a list of 11 data frames with one common variable in each (prov). I'd like to use lapply to go through and recode one particular level of that common variable. I can get the recode to work, but it only returns the variable that has been recoded. I need the whole data frame with the recoded variable. Thank you for your help. Reproducible data and my current code are below. ####Sample Data mylist<-list(df1=data.frame(a=seq(1,10,1), prov=c(rep('QUE', 5), rep('BC', 5))), df2=data.frame(a=seq(1,10,1), prov=c(rep('Que...
2005 Jul 28
1
Unexpected behavior in recode{car}
Thanks to the R creators for such a great statistical system. Thanks to the R help list, I have (finally) gotten far enough in R to have a question I hope to be worth posting. I'm using the recode function from John Fox's car package and have encountered some unexpected behavior. Consider the following example: ## Begin cut-and-paste example require( car ) set.seed(12345) nn <-
2010 Jun 15
1
Problem with the recode function
Hello, I am using the recode() function in Rcmdr and the result is not what I expect so I am almost sure I did something wrong but what... > test <- data.frame(x=1:10) > library(car) > recode(test$x,'1:5=0 ; else=1', as.factor.result=TRUE) [1] 0 0 0 0 0 1 1 1 1 1 Levels: 0 1 BUT > library(Rcmdr) # recode from the car package is now masked Now I recode test$x
2008 May 28
1
manipulating multiply imputed data sets
Hi folks, I have five imputed data sets and would like to apply the same recoding routines to each. I could do this sort of thing pretty easily in Stata using MIM, but I've decided to go cold turkey on other stats packages as a incentive for learning more about R. Most of the recoding is for nominal variables, like race, religion, urbanicity, and the like. So, for example, to recode race
2008 Mar 18
1
Updating selected variables in a data frame
Dear list, I'd like to update certain rows/columns in a data frame with new values. The application is that survey respondents may give an answer of "Other" to a categorical question and then provide some text describing what they mean. This text is then reviewed and placed into a category. These edits or recodes then need to be merged back into the main dataset. A small example
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
2003 Dec 06
1
recode{car} does not work as expected?
...th 1 if PRE1RES is c and zero otherwise. However, if I type > FCI$PRE1[0] I get as result: factor(0) Levels: 0 1 FCI$PRE1 is not a numeric variable, and I get instead a factor. Recode seems to work fine as it correctly replaces the c's for 1 and other results for 0, but the fact that the recoded variable is a factor does not work for me. Any suggestions on what I am doing wrong? I am using R 1.7.1 (2) on a Windows XP machine. Thanks, Julie [[alternative HTML version deleted]]
2003 Nov 04
2
line breaks in recode
Dear all, it seems to be that 'recode' can't handle any line breaks in its code. The following command causes no problem: datameta$smpid.r <- recode(datameta$smpid,"c(101,25,167,45,75)=25;c(104,51)=51") But if I type ... datameta$smpid.r <-recode(datameta$smpid, "c(101,25,167,45,75)=25; c(104,51)=51") ... the result is a syntax error.
2010 Apr 14
3
Problem with recode -Error in parse(text = range[[1]][1]) : unexpected end of input in " c(0"
Dear colleagues, in the help archive there was a previous person who encountered a problem with the "recode" command in the car library. I'm not sure if that was solved, there was no posting to that effect, but I'm having the same problem. I'm trying to recode a numeric variable with values from 0-100 into a binary variable with values (0,1). The following command:
2008 Jan 07
1
recode() function results in logical output, not factor output
Dear R Users: I have race-ethnicity groups identified in the factor variable Ethnic_G. I need to collapse Ethnic_G into a new variable with only two factors, 1 (White, non-Hispanic) and 2 (Minority). As seen in the code and output below, the recoded race-ethnicity variable is put into logical format, not factor format. I've used library(car) and the package was updated. Any ideas on how to fix this problem would be apprecidated. Thanks in advance! Best wishes. Tom > ############################################################...
2013 May 07
2
recode categorial vars into binary data
...If I use ifelse I have a problem with cases that share the same rank being all median. e.g. df<-as.data.frame(cbind(snr=c(1,2,3,4,5,6,7,8,9,10),k1=c(1,1,4,2,3,2,2,5,2,2),k2=c(1,2,3,2,1,2,1,3,3,2),result=c(4,3,5,4,2,6,4,4,2,3))) now I want to recode k1 and k2 so that I have half of the values recoded 0 and half recoded 1, split around the median point. The median of k1 is 2 which would lead to unequal groupsize if used 2 as cutoff, so all values k1=2 should be recoded 1 or 0 randomly until both categories have the same length. something like df.rec<-as.data.frame(cbind(snr=c(1,2,3,4,5,6,7,...
2013 May 07
2
recode categorial vars into binary data
...If I use ifelse I have a problem with cases that share the same rank being all median. e.g. df<-as.data.frame(cbind(snr=c(1,2,3,4,5,6,7,8,9,10),k1=c(1,1,4,2,3,2,2,5,2,2),k2=c(1,2,3,2,1,2,1,3,3,2),result=c(4,3,5,4,2,6,4,4,2,3))) now I want to recode k1 and k2 so that I have half of the values recoded 0 and half recoded 1, split around the median point. The median of k1 is 2 which would lead to unequal groupsize if used 2 as cutoff, so all values k1=2 should be recoded 1 or 0 randomly until both categories have the same length. something like df.rec<-as.data.frame(cbind(snr=c(1,2,3,4,5,6,7,...
2008 May 17
1
Recode
Hi! Using recode in cars package, I tryed to use the following: recode(data$nrcomp, "lo:5='0 to 5'; 5:hi='bigger than 5'") I got: Erro em parse(text = strsplit(term, "=")[[1]][2]) : unexpected end of input in "'0 to 5" When I try only numbers, or only text, it's ok, but when I try to combine numbers and text, I got a error... Any help?
2009 Nov 18
2
recode according to old levels
Dear R-users, i try to recode a factor according to old levels F <- factor(sample(c(rep("A", 4), rep("B",2), rep("C",5)))) recode(F, "levels(F)[c(1,3)]='X'; else='Y'") i tried to work with eval or expression around levels(F)[c(1,3)], but nothing seems to work. Many thanks if anyone could tell me what i've missed and what's
2008 Mar 27
1
Recode factors
I know this comes up, but I didn't see my exact issue in the archives. I have variables in a dataframe that need to be recoded. Here is what I'm dealing with I have a factor called aa > class(aa) [1] "factor" > table(aa) aa * 0 1 2 3 A B C D L N T 0 0 1908 725 2089 0 0 67 0 0 2 1 6 I need to recode everything that is not a numer...
2006 Jul 02
2
how to recode in my dataset?
Dear Rusers, My question is about "recode variables". First, i'd like to say something about the idea of recoding: My dataset have three variables:type,soiltem and airtem,which means grass type, soil temperature and air temperature. As we all known, the change of air temperature is greater than soil temperature,so the values in those two different temperaturemay represent different
2009 Jun 12
2
Sweave recode(car) and Lyx, compiling but not executing on Mac
I am just beginning to use Sweave with Lyx on a Mac (R2.8.1). I have 12 chunks of Sweave code that work fine, but this piece: <<>>= library(car)
2012 Jul 24
3
package memisc: recode examples
Dear people, Yesterday I looked at the recode command in the memisc package and ran the following example stated in the manual: x <- as.item(sample(1:6,20,replace=TRUE), labels=c( a=1, b=2, c=3, d=4, e=5, f=6)) print(x) f <- as.factor(x) f recode(f,
2011 Jul 29
1
Apostrophes in R Commander in recode
Dear colleagues, I'm using R64 (2.13) on Mac OS 10.6.8 and I've encountered a problem with the recode function in Rcommander. The application cannot deal with apostrpohes ( ' ) do not. I've got a factor from the 2008 Canada Election study (highest level of schooling) and some of the values include "Bachelor's Degree" , "Master's Degree". I've