similar to: recode according to old levels

Displaying 20 results from an estimated 10000 matches similar to: "recode according to old levels"

2007 Dec 02
1
How to recode a factor level (within the list)?
#Dear R-users, #I have a data.frame like this: y1 <- rnorm(10) + 6.8 y2 <- rnorm(10) + (1:10*1.7 + 1) y3 <- rnorm(10) + (1:10*6.7 + 3.7) y <- c(y1,y2,y3) x <- rep(1:3,10) f <- gl(2,15, labels=paste("lev", 1:2, sep="")) g <- seq(as.Date("2000/1/1"), by="day", length=30) DF <- data.frame(x=x,y=y, f=f, g=g) DF$g[DF$x == 1] <- NA
2013 Feb 19
2
recode data according to quantile breaks
Dear R-List, I would like to recode my data according to quantile breaks, i.e. all data within the range of 0%-25% should get a 1, >25%-50% a 2 etc. Is there a nice way to do this with all columns in a dataframe. e.g. df<-
2011 Feb 04
2
recode according to specific sequence of characters within a string variable
Dear R-List, I have a dataframe with one column "name.of.report" containing character values, e.g. >df$name.of.report "jeff_2001_teamx" "teamy_jeff_2002" "robert_2002_teamz" "mary_2002_teamz" "2003_mary_teamy" ... (i.e. the bit of interest is not always at same position) Now I want to recode the column "name.of.report"
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
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 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
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 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
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 Oct 24
2
Recode function car package erases previous values
Hi all, I am attempting to create a new variable based on values of other variables. The variable is called pharm. It basically takes the numeric code of 1 as yes and 0 to be No from the variable B20_C1 (a question on a survey). However, I would also like to have a level for non-respondents and these are captured in the variable nr.B20C, which is a 1 when there is a non-response on the whole group
2013 May 07
2
recode categorial vars into binary data
Dear R-List, I would like to recode categorial variables into binary data, so that all values above median are coded 1 and all values below 0, separating each var into two equally large groups (e.g. good performers = 0 vs. bad performers =1). I have not succeeded so far in finding a nice solution to do that in R. I thought there might be a better way than ordering each column and recoding the
2013 May 07
2
recode categorial vars into binary data
Dear R-List, I would like to recode categorial variables into binary data, so that all values above median are coded 1 and all values below 0, separating each var into two equally large groups (e.g. good performers = 0 vs. bad performers =1). I have not succeeded so far in finding a nice solution to do that in R. I thought there might be a better way than ordering each column and recoding the
2001 Mar 27
4
recode vector values to NA
Greetings, I'm in the painful process of migrating from SAS to R. In the process I've discovered that there are some basic things that I am getting hung up on. The most basic is the simple recoding of variables. Suppose I create a vector x <- rnorm(10000) and I want to recode all values of x > 1.5 to NA. How would I do that in R? TIA Cheers, Patrick
2003 Dec 06
1
recode{car} does not work as expected?
Hi to all, I am having a problem when using recode from the car package. I have a variable that is char and when I use recode to create a new variable that is supposed to be numeric I get a factor variable. Here is the code I am using: > FCI$PRE1 <- recode (PRE1RES, " c('C', 'c')=1 ; else = 0 ; as.factor.result=FALSE ") So, if I understand correctly the recode
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
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.
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
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
2011 Oct 03
1
function recode within sapply
Dear List, I am using function recode, from package car, within sapply, as follows: L3 <- LETTERS[1:3] (d <- data.frame(cbind(x = 1, y = 1:10), fac1 = sample(L3, 10, replace=TRUE), fac2 = sample(L3, 10, replace=TRUE), fac3 = sample(L3, 10, replace=TRUE))) str(d) d[, c("fac1", "fac2")] <- sapply(d[, c("fac1", "fac2")], recode, "c('A',
2011 Mar 31
1
error in recode.defalt ....object '.data' not found
Dear colleagues, working with the data frame below, trying to reverse two variables I the error message below. i searched through the help list but could not find any postings which could help me solve the situation. I tried attaching and detaching the data frame to no avail. Yours, Simon Kiss *DATA FRAME 'data.frame': 1569 obs. of 9 variables: $ equal : num 3 4 3 2 3 4 2 3 2 2 ...