Displaying 20 results from an estimated 2000 matches similar to: "conditional data replace (recode, change or whatsoever)"
2011 Aug 11
3
value.labels
Hello R people,
I have a "data.frame". Status variable has 3 values. 0->alive, 1->dead and
2->missed
Status as a factor have correct levels. Levels and labels output as follows;
levels(Adbf$status); labels(Adbf$status)
[1] "0" "1" "2"
[1] "1" "2" "3" "4" "5" "6"
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 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 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 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
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 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?
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',
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 <-
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 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 ...
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:
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)
2009 Oct 22
1
Recode issue
I am having trouble with the recode function that is provided in the
CAR package. I trying to create a new factors based on existing factors.
E.g.
>x <- as.factor(1:20)
>y <- recode(x, " 1:5='A'; 6:10='B'; 11:15='C'; 16:20='D' ")
>y
[1] A A A A A 6 7 8 9 A A A A A A A A A A A
Levels: 6 7 8 9 A
Could someone point to me, my error?
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
2011 Jun 01
5
Recode numbers
Dear all,
I have two sets of numbers that look like
a <- c(1, 2, 3, 3, 4, 4, 5, 6, 1, 2, 2, 3, 1, 2, 1, 2, 3, 3, 4, 5, 1, 2, 3,
4)
b <- c(1, 5, 8, 9, 14, 20, 3, 10, 12, 6, 16, 7, 11, 13, 17, 18, 2, 4, 15,
19)
I just want to use ?b? to encode ?a? so that ?a? looks like
a1<- c(1, 5, 8, 8, 9, 9, 14, 20, 3, 10, 10, 12, 6, 16, 7, 11, 13, 13, 17,
18, 2, 4, 15, 19)
Does anyone have a
2006 Oct 23
2
Help with "recode" and "factor" functions
I have a data set with seven inputs. Four of which are categorical. For my
midterm, my professor wants us to scale all the inputs. This means, I
pressume, that I have to use 'recode' or 'factor' to transform the
categorical data in numerical. For example, one input variable is
'race=(b,w,h,o)'. I just want to assign a numerical value to all
'b,w,h,o'. I
2012 Apr 12
4
Recode Variable
Ein eingebundener Text mit undefiniertem Zeichensatz wurde abgetrennt.
Name: nicht verf?gbar
URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20120412/74331e9a/attachment.pl>
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