Re: [R] Question about cut()

2012-11-06 Thread Brian Diggs
On 11/2/2012 11:11 AM, Ni, Shenghua wrote: r-c(1,1,9,1,1,1) col_no-cut(r,c(0,2,3,6,8,10,100)) levels(col_no)-c(2%,2-4%,4-6%,6-8%,8-10%,10%) col_no [1] 2% 2% 8-10% 2% 2% 2% Levels: 2% 2-4% 4-6% 6-8% 8-10% 10% Yes. (Or, I get the same output from this code. What is the question?)

Re: [R] Question about cut()

2012-11-06 Thread David Winsemius
On Nov 2, 2012, at 11:51 AM, Berend Hasselman wrote: On 02-11-2012, at 19:11, Ni, Shenghua wrote: r-c(1,1,9,1,1,1) col_no-cut(r,c(0,2,3,6,8,10,100)) levels(col_no)-c(2%,2-4%,4-6%,6-8%,8-10%,10%) col_no [1] 2% 2% 8-10% 2% 2% 2% Levels: 2% 2-4% 4-6% 6-8% 8-10% 10% Where is

Re: [R] Question about cut()

2012-11-06 Thread peter dalgaard
On Nov 6, 2012, at 22:16 , Brian Diggs wrote: On 11/2/2012 11:11 AM, Ni, Shenghua wrote: r-c(1,1,9,1,1,1) col_no-cut(r,c(0,2,3,6,8,10,100)) levels(col_no)-c(2%,2-4%,4-6%,6-8%,8-10%,10%) col_no [1] 2% 2% 8-10% 2% 2% 2% Levels: 2% 2-4% 4-6% 6-8% 8-10% 10% Yes. (Or, I get the

[R] Question about cut()

2012-11-02 Thread Ni, Shenghua
r-c(1,1,9,1,1,1) col_no-cut(r,c(0,2,3,6,8,10,100)) levels(col_no)-c(2%,2-4%,4-6%,6-8%,8-10%,10%) col_no [1] 2% 2% 8-10% 2% 2% 2% Levels: 2% 2-4% 4-6% 6-8% 8-10% 10% [[alternative HTML version deleted]] __ R-help@r-project.org

Re: [R] Question about cut()

2012-11-02 Thread Berend Hasselman
On 02-11-2012, at 19:11, Ni, Shenghua wrote: r-c(1,1,9,1,1,1) col_no-cut(r,c(0,2,3,6,8,10,100)) levels(col_no)-c(2%,2-4%,4-6%,6-8%,8-10%,10%) col_no [1] 2% 2% 8-10% 2% 2% 2% Levels: 2% 2-4% 4-6% 6-8% 8-10% 10% Where is the question? Berend

[R] Question about cut()

2010-12-14 Thread Tianchan Niu
Dear all, I would like to use cut() to make numerics to factors, the sample codes are as follows. However, the result is not what I want, since r[3] = 9 should be in the interval of 8-10% rather than 2-4%. Maybe cut() is not the right function to use for my situation. Please help. r -

Re: [R] Question about cut()

2010-12-14 Thread Gavin Simpson
On Tue, 2010-12-14 at 15:40 +, Tianchan Niu wrote: Dear all, I would like to use cut() to make numerics to factors, the sample codes are as follows. However, the result is not what I want, since r[3] = 9 should be in the interval of 8-10% rather than 2-4%. Maybe cut() is not the right

Re: [R] Question about cut()

2010-12-14 Thread Ben Bolker
Tianchan Niu niu at isis.georgetown.edu writes: Dear all, I would like to use cut() to make numerics to factors, the sample codes are as follows. However, the result is not what I want, since r[3] = 9 should be in the interval of 8-10% rather than 2-4%. Maybe cut() is not the right function

Re: [R] Question about cut()

2010-12-14 Thread Gerrit Eichner
Tianchan, why aren't you just using col_no - cut(r,c(0,2,4,6,8,10,100)) levels(col_no) - c(2%,2-4%,4-6%,6-8%,8-10%,10%) ? Your use of as.numeric() is nonsensical; check step by step what is happening with that. Hth, Gerrit On Tue, 14 Dec 2010, Tianchan Niu wrote: Dear all, I would like