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
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
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
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<-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]]
__
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
Tianchan Niu 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 funct
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 r
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 <- c(1
9 matches
Mail list logo