Hi,
Try this:
dat1<-structure(list(var1 = c(97, 97, 98, 98, 97, 99, 97,
98, 99, 98, 99, 98, 98, 97, 97, 98, 99, 98, 96, 98, 98, 99, 98,
98, 99, 99, 98, 99, 98, 99, 99, 99, 99, 98, 99, 96, 99, 98, 98,
99, 97, 98, 99, 99, 97, 99, 99, 98, 98, 98, 99, NA, 99, 98, 98,
98, 98, 98, 98, 98, 99, 99, 98, 99, 99, 98, 98, 99, 99, 97, 98,
98, 98, 99, 98, 98, 98, 99, 98, 98)), .Names = "var1", row.names =
c(NA,
80L), class = "data.frame")
unique(dat1[,1])
#[1] 97 98 99 96 NA
dat2<-dat1[!is.na(dat1)]
cut2(dat2,g=4)
# [1] (96,97]?? (96,97]?? (97,98]?? (97,98]?? (96,97]?? (98,99]?? (96,97]?
?#[8] (97,98]?? (98,99]?? (97,98]?? (98,99]?? (97,98]?? (97,98]?? (96,97]?
#[15] (96,97]?? (97,98]?? (98,99]?? (97,98]?? (-Inf,96] (97,98]?? (97,98]?
#[22] (98,99]?? (97,98]?? (97,98]?? (98,99]?? (98,99]?? (97,98]?? (98,99]?
#[29] (97,98]?? (98,99]?? (98,99]?? (98,99]?? (98,99]?? (97,98]?? (98,99]?
#[36] (-Inf,96] (98,99]?? (97,98]?? (97,98]?? (98,99]?? (96,97]?? (97,98]?
#[43] (98,99]?? (98,99]?? (96,97]?? (98,99]?? (98,99]?? (97,98]?? (97,98]?
#[50] (97,98]?? (98,99]?? (98,99]?? (97,98]?? (97,98]?? (97,98]?? (97,98]?
#[57] (97,98]?? (97,98]?? (97,98]?? (98,99]?? (98,99]?? (97,98]?? (98,99]?
#[64] (98,99]?? (97,98]?? (97,98]?? (98,99]?? (98,99]?? (96,97]?? (97,98]?
#[71] (97,98]?? (97,98]?? (98,99]?? (97,98]?? (97,98]?? (97,98]?? (98,99]?
#[78] (97,98]?? (97,98]?
#Levels: (-Inf,96] (96,97] (97,98] (98,99]
A.K.
----- Original Message -----
From: Charles Determan Jr <deter088 at umn.edu>
To: r-help at r-project.org
Cc:
Sent: Wednesday, October 17, 2012 3:42 PM
Subject: [R] cut2 error
To R users,
I am trying to use cut2 function from the 'Hmisc' library.? However,
when I
try and run the function on the following variable, I get an error message
(displayed below).? I suspect it is because of the NA but I have no idea
how to address the error.? Many thanks to any insights.
structure(list(var1 = c(97, 97, 98, 98, 97, 99, 97,
98, 99, 98, 99, 98, 98, 97, 97, 98, 99, 98, 96, 98, 98, 99, 98,
98, 99, 99, 98, 99, 98, 99, 99, 99, 99, 98, 99, 96, 99, 98, 98,
99, 97, 98, 99, 99, 97, 99, 99, 98, 98, 98, 99, NA, 99, 98, 98,
98, 98, 98, 98, 98, 99, 99, 98, 99, 99, 98, 98, 99, 99, 97, 98,
98, 98, 99, 98, 98, 98, 99, 98, 98)), .Names = "var1", row.names =
c(NA,
80L), class = "data.frame")
cut2(dat[,1], g=4)
Warning message:
In min(xx[xx > upper]) : no non-missing arguments to min; returning Inf
Regards,
Charles
??? [[alternative HTML version deleted]]
______________________________________________
R-help at r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.