Re: [R] Recoding multiple columns consistently

2007-08-29 Thread Uwe Ligges
Ron Crump wrote: Hi, I have a dataframe that contains pedigree information; that is individual, sire and dam identities as separate columns. It also has date of birth. These identifiers are not numeric, or not sequential. Obviously, an identifier can appear in one or two columns,

Re: [R] Recoding multiple columns consistently

2007-08-29 Thread Jim Lemon
Ron Crump wrote: Hi, I have a dataframe that contains pedigree information; that is individual, sire and dam identities as separate columns. It also has date of birth. These identifiers are not numeric, or not sequential. Obviously, an identifier can appear in one or two columns,

[R] Recoding multiple columns consistently

2007-08-28 Thread Ron Crump
Hi, I have a dataframe that contains pedigree information; that is individual, sire and dam identities as separate columns. It also has date of birth. These identifiers are not numeric, or not sequential. Obviously, an identifier can appear in one or two columns, depending on whether it was a

[R] Recoding

2007-06-11 Thread David Scott
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

Re: [R] Recoding

2007-06-11 Thread David Barron
I've used the one in car with no problems. For grouping a continuous variable you might also consider cut. On 11/06/07, David Scott [EMAIL PROTECTED] wrote: 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

[R] recoding question

2007-03-11 Thread Lauri Nikkinen
Hi R-users, I have a data frame like this: photographer category picture points Hannu kalat limamikko 1 Teemu kalat verkkovaja 3 Hate kalat munat puoliks padassa 6 Hannu kalat isokala 8 Teemu kasvit, sienet ja muut eliöt harppi 2 Hate kasvit, sienet ja muut eliöt pyynikki 2 Petteri kasvit,

Re: [R] recoding question

2007-03-11 Thread Petr Klasterecky
Hi, I suppose you wouldn't mind rearranging rows in your dataframe. So just use order() to sort your dataframe according to category (first) and points (second). Now add a new column with values (3,2,1,0,...,0,3,2,1,0...etc.) You can construct such vector using by() or a simple for-loop.

[R] Recoding categorical variables

2006-10-25 Thread Murray Jorgensen
I want to recode an integer-valued variable y so that its values become 1:length(y). I can do this using a loop but maybe someone can suggest code without a loop. My code is this: y - round(20*runif(25)) table(y) suy - sort(unique(y)) m - length(suy) z - y + max(suy) for(i in 1:m) z[y==suy[i]]

Re: [R] Recoding categorical variables

2006-10-25 Thread John Fox
Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Murray Jorgensen Sent: Wednesday, October 25, 2006 7:13 PM To: r-help@stat.math.ethz.ch Subject: [R] Recoding categorical variables I want to recode an integer-valued variable y so that its values become 1:length

Re: [R] Recoding categorical variables

2006-10-25 Thread Murray Jorgensen
@stat.math.ethz.ch Subject: [R] Recoding categorical variables I want to recode an integer-valued variable y so that its values become 1:length(y). I can do this using a loop but maybe someone can suggest code without a loop. My code is this: y - round(20*runif(25)) table(y) suy - sort(unique(y

[R] recoding large number of categories (select in SAS)

2005-01-19 Thread Denis Chabot
Hi, I have data on stomach contents. Possible prey species are in the hundreds, so a list of prey codes has been in used in many labs doing this kind of work. When comes time to do analyses on these data one often wants to regroup prey in broader categories, especially for rare prey. In SAS

Re: [R] recoding large number of categories (select in SAS)

2005-01-19 Thread Philippe Grosjean
Does ?cut answers to your question? Best, Philippe Grosjean ..°})) ) ) ) ) ) ( ( ( ( (Prof. Philippe Grosjean ) ) ) ) ) ( ( ( ( (Numerical Ecology of Aquatic Systems ) ) ) ) ) Mons-Hainaut University, Pentagone (3D08) ( ( ( ( (

Re: [R] recoding large number of categories (select in SAS)

2005-01-19 Thread james . holtman
: Sent by: Subject: [R] recoding large number of categories (select in SAS) [EMAIL PROTECTED

Re: [R] recoding large number of categories (select in SAS)

2005-01-19 Thread Peter Dalgaard
Philippe Grosjean [EMAIL PROTECTED] writes: Does ?cut answers to your question? That's one way, but it tends to get messy to get the names right. You might consider using the rather little-known variant of levels assignment: preyGR - prey # or factor(prey) if it wasn't one already

RE: [R] recoding large number of categories (select in SAS)

2005-01-19 Thread John Fox
@stat.math.ethz.ch; Denis Chabot Subject: Re: [R] recoding large number of categories (select in SAS) Philippe Grosjean [EMAIL PROTECTED] writes: Does ?cut answers to your question? That's one way, but it tends to get messy to get the names right. You might consider using

[R] Recoding factors

2004-10-18 Thread Neil Leonard
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 __ [EMAIL PROTECTED]

Re: [R] Recoding factors

2004-10-18 Thread Uwe Ligges
Neil Leonard wrote: 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? Depends on what you are going to do with the Twin ... Uwe Ligges

Re: [R] Recoding factors

2004-10-18 Thread Neil Leonard
I want Twin and Triplet to both be recoded as Multiple Neil On 18/10/2004, at 7:43 PM, Uwe Ligges wrote: Neil Leonard wrote: 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

Re: [R] Recoding factors

2004-10-18 Thread Prof Brian Ripley
On Mon, 18 Oct 2004, Uwe Ligges wrote: Neil Leonard wrote: 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?

Re: [R] Recoding factors

2004-10-18 Thread Neil Leonard
Yes that's it. Thanks Neil On 18/10/2004, at 7:57 PM, Prof Brian Ripley wrote: On Mon, 18 Oct 2004, Uwe Ligges wrote: Neil Leonard wrote: 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

Re: [R] Recoding factors

2004-10-18 Thread Chuck Cleland
See ?levels. I think you want something like the following: levels(myfact) - c(Singleton, Multiple, Multiple) Neil Leonard wrote: 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

[R] Recoding scores of negatively worded item

2004-07-03 Thread a . prioglio
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

Re: [R] Recoding scores of negatively worded item

2004-07-03 Thread Jonathan Baron
On 07/03/04 16:45, [EMAIL PROTECTED] wrote: 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,

Re: [R] Recoding scores of negatively worded item

2004-07-03 Thread Gabor Grothendieck
Jonathan Baron baron at psych.upenn.edu writes: : ces$score - ifelse(ces$question %in% c(1,3,5),5-ces$score,ces$score) One minor improvement in readability might be: ces$score - with(ces, ifelse(question %in% c(1,3,5), 5-score, score)) __ [EMAIL

Re: [R] Recoding scores of negatively worded item

2004-07-03 Thread a . prioglio
On Sat, Jul 03, 2004 at 12:17:11PM -0400, Jonathan Baron wrote: b) why there is a different behavior from the command line and from a script? Could the problem be on the line before the one that gives the error? I guess I discovered what was the issue ( I knew it was something silly) In the

RE: [R] Recoding a multiple response question into a series of 1, 0 variables

2004-06-08 Thread Philippe Grosjean
(http://www.sciviews.org) ( ( ( ( ( ... -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of Jonathan Baron Sent: Tuesday, 08 June, 2004 04:45 To: Greg Blevins Cc: R-Help Subject: Re: [R] Recoding

[R] Recoding a multiple response question into a series of 1, 0 variables

2004-06-07 Thread Greg Blevins
Hello R folks. 1) The question that generated the data, which I call Qx: Which of the following 5 items have you performed in the past month? (multipe response) 2) How the data is coded in my current dataframe: The first item that a person selected is coded under a field called Qxfirst; the

Re: [R] Recoding a multiple response question into a series of 1, 0 variables

2004-06-07 Thread Jonathan Baron
On 06/07/04 21:28, Greg Blevins wrote: Hello R folks. 1) The question that generated the data, which I call Qx: Which of the following 5 items have you performed in the past month? (multipe response) 2) How the data is coded in my current dataframe: The first item that a person selected is

Re: [R] Recoding a multiple response question into a series of 1, 0 variables

2004-06-07 Thread Jonathan Baron
On 06/07/04 22:45, Jonathan Baron should have written: for (i in [whatever]) Y[i,][X[i,]] - 1 __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide!

[R] recoding variables

2004-03-11 Thread Shayna Strom
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

Re: [R] recoding variables

2004-03-11 Thread Sundar Dorai-Raj
Shayna Strom wrote: 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

Re: [R] recoding variables

2004-03-11 Thread Roger D. Peng
Basically, you want to use cut(). For example, x - 1:20 cut(x, c(0, 8, 15, 20)) This divides x into a factor with levels (0,8], (8,15], and (15,20]. -roger Shayna Strom wrote: 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

Re: [R] recoding variables

2004-03-11 Thread Sundar Dorai-Raj
Shayna Strom wrote: 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

Re: [R] recoding variables

2004-03-11 Thread Spencer Graves
(tst - cut(1:11, c(-Inf, 3, 5, Inf))) [1] (-Inf,3] (-Inf,3] (-Inf,3] (3,5](3,5](5,Inf] (5,Inf] (5,Inf] [9] (5,Inf] (5,Inf] (5,Inf] Levels: (-Inf,3] (3,5] (5,Inf] class(tst) [1] factor hope this helps. spencer graves Shayna Strom wrote: Hi, I was hoping someone could help me.

Re: [R] recoding variables

2004-03-11 Thread Philipp Pagel
Hi! 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. You are looking for cut(): a - runif(15) a [1] 0.19109987 0.78808597 0.78458256 0.31355035 0.02076274 0.82287287 0.75260382 0.82627690 0.14775167

[R] Recoding problem

2003-12-08 Thread Peter Flom
Hello I have the following variables, all of which are logicals fmar15 fcoc15 fher15fcrk15fidu15 what I would like is a variable drug15 which equals idu if fidu15 is T; crk if fidu15 is F but fcrk is T, her if fher15 is T but fcrk15 and fidu15 are F and so on What's the best way

Re: [R] Recoding problem

2003-12-08 Thread Ray Brownrigg
I have the following variables, all of which are logicals fmar15 fcoc15 fher15fcrk15fidu15 what I would like is a variable drug15 which equals idu if fidu15 is T; crk if fidu15 is F but fcrk is T, her if fher15 is T but fcrk15 and fidu15 are F and so on What's the best way