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.14775

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

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 me?

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 me?

[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