[R] Help resolving error in quantcut

Chris Anderson
Wed, 08 Jul 2009 06:41:54 -0000

I am trying to use the quantcut function to create deciles, but I am getting the
error below. I am new to using this function and do not know how to properly use
the options or some other conversion that is necessary.
#initial summary using describe function in Hmisc library
DegreeBurn4th
      n missing  unique    Mean     .05     .10     .25     .50     .75     .90
.95
     76     133      16  0.0325  0.0000  0.0000  0.0000  0.0000  0.0225  0.0900
0.1725
                  0 0.01 0.02 0.03 0.04 0.05 0.06 0.08 0.09 0.12 0.16 0.17 0.18
0.24 0.36 0.5
Frequency 48    6    3    4    2    2    1    1    2    1    1    1    1    1
1   1
%             63    8    4    5    3    3    1    1    3    1    1    1    1
1    1   1
> degree.quant = quantcut(DegreeBurn4th, q=seq(0, 1, 0.1),
labels=F,na.rm=TRUE)
Error in if (sum(flag) == 0) return(cut) else return(min(x[flag], na.rm =
na.rm)) :
  missing value where TRUE/FALSE needed

#orignal data
>print(DegreeBurn4th)
  [1] 0.09 0.00 0.00   NA   NA 0.03   NA 0.02   NA 0.00 0.01 0.00   NA   NA   NA
NA   NA 0.00   NA 0.05 0.03 0.00   NA 0.02 0.00   NA 0.00   NA   NA 0.16   NA
NA 0.24
 [34]   NA   NA 0.00   NA 0.00 0.08   NA   NA   NA 0.00 0.00   NA   NA 0.01   NA
0.09   NA 0.00 0.00 0.00 0.06   NA 0.00   NA   NA 0.00   NA   NA 0.00 0.01   NA
NA 0.00
 [67]   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA 0.00
0.00   NA   NA 0.00   NA 0.05 0.00   NA   NA   NA 0.00 0.02 0.18   NA   NA   NA
0.03   NA
[100]   NA 0.00   NA   NA   NA 0.36   NA   NA   NA   NA 0.00 0.00 0.00   NA 0.00
NA 0.17   NA 0.00   NA   NA   NA 0.00   NA 0.00 0.00 0.00   NA   NA 0.12 0.00
NA 0.01
[133] 0.00   NA   NA   NA   NA 0.00 0.00   NA 0.01 0.00 0.00   NA   NA 0.00 0.04
NA   NA   NA 0.00 0.00   NA 0.03   NA 0.00   NA 0.00   NA   NA 0.01 0.00 0.00
NA   NA
[166]   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA 0.00   NA   NA
NA   NA   NA   NA   NA   NA   NA   NA 0.50   NA   NA   NA   NA   NA   NA   NA
NA 0.04
[199]   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA
#convert missing to zero
> DegreeBurn4th[is.na(DegreeBurn4th)]<-0.00
> print(DegreeBurn4th)
  [1] 0.09 0.00 0.00 0.00 0.00 0.03 0.00 0.02 0.00 0.00 0.01 0.00 0.00 0.00 0.00
0.00 0.00 0.00 0.00 0.05 0.03 0.00 0.00 0.02 0.00 0.00 0.00 0.00 0.00 0.16 0.00
0.00 0.24
 [34] 0.00 0.00 0.00 0.00 0.00 0.08 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.01 0.00
0.09 0.00 0.00 0.00 0.00 0.06 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.01 0.00
0.00 0.00
 [67] 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
0.00 0.00 0.00 0.00 0.00 0.05 0.00 0.00 0.00 0.00 0.00 0.02 0.18 0.00 0.00 0.00
0.03 0.00
[100] 0.00 0.00 0.00 0.00 0.00 0.36 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
0.00 0.17 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.12 0.00
0.00 0.01
[133] 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.01 0.00 0.00 0.00 0.00 0.00 0.04
0.00 0.00 0.00 0.00 0.00 0.00 0.03 0.00 0.00 0.00 0.00 0.00 0.00 0.01 0.00 0.00
0.00 0.00
[166] 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.50 0.00 0.00 0.00 0.00 0.00 0.00 0.00
0.00 0.04
[199] 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
0.00
> degree.quant = quantcut(DegreeBurn4th, q=seq(0, 1, 0.1),
labels=F,na.rm=TRUE)
Error in if (pairs[1, i] == pairs[1, i - 1] && pairs[1, i] == pairs[2,
:
  missing value where TRUE/FALSE needed
> degree.quant = quantcut(DegreeBurn4th, q=seq(0, 1, 0.1),
labels=F,include.lowest=TRUE)
Error in cut.default(x[!flag], breaks = newquant, include.lowest = TRUE,  :
  formal argument "include.lowest" matched by multiple actual
arguments
> degree.quant = quantcut(DegreeBurn4th, q=seq(0, 1, 0.1),
labels=F,include.lowest=F)
Error in cut.default(x[!flag], breaks = newquant, include.lowest = TRUE,  :
  formal argument "include.lowest" matched by multiple actual
arguments
> degree.quant = quantcut(DegreeBurn4th, q=seq(0, 1, 0.1),
labels=F,include.lowest=T)
Error in cut.default(x[!flag], breaks = newquant, include.lowest = TRUE,  :
  formal argument "include.lowest" matched by multiple actual
arguments
>



Chris Anderson

http://www.seocodebreaker.com/?thankyou-page=429
____________________________________________________________
Criminal Lawyers - Click here.
http://thirdpartyoffers.netzero.net/TGL2241/fc/BLSrjpYbd6xeB8PyC2qYcdt9oup93MpUqzGGHKa4mySkwS9XNfuLPlvlNq4/
	[[alternative HTML version deleted]]