Dieter Menne wrote: > > > It used to be quite tricky, but on popular request Brian Ripley has added > an example how to extract the intervals using regular expression on the > bottom of the examples for cut (note:cut in base, not cut2 in Hmisc). > >
Thank you, but the regular expression example doesn't seem to work correctly. > labs<-levels(df$p_bin) > labs [1] " 0" " 1" " 2" " 3" " 4" " 5" [7] " 6" " 7" " 8" " 9" "10" "11" [13] "12" "13" "14" "15" "16" "17" [19] "18" "19" "20" "[21, 24)" "[24, 28)" "[28, 35)" [25] "[35, 49)" "[49, 69)" "[69, 96)" "[96,270]" > cbind(lower = as.numeric( sub("\\((.+),.*", "\\1", labs) ), upper = > as.numeric( sub("[^,]*,([^]]*)\\]", "\\1", labs) )) Warning in cbind(lower = as.numeric(sub("\\((.+),.*", "\\1", labs)), upper = as.numeric(sub("[^,]*,([^]]*)\\]", : NAs introduced by coercion Warning in cbind(lower = as.numeric(sub("\\((.+),.*", "\\1", labs)), upper = as.numeric(sub("[^,]*,([^]]*)\\]", : NAs introduced by coercion lower upper [1,] 0 0 [2,] 1 1 [3,] 2 2 [4,] 3 3 [5,] 4 4 [6,] 5 5 [7,] 6 6 [8,] 7 7 [9,] 8 8 [10,] 9 9 [11,] 10 10 [12,] 11 11 [13,] 12 12 [14,] 13 13 [15,] 14 14 [16,] 15 15 [17,] 16 16 [18,] 17 17 [19,] 18 18 [20,] 19 19 [21,] 20 20 [22,] NA NA [23,] NA NA [24,] NA NA [25,] NA NA [26,] NA NA [27,] NA NA [28,] NA 270 -- Any ideas? Thank you, -S -- View this message in context: http://www.nabble.com/cut2-once%2C-bin-twice...-tp26020736p26027643.html Sent from the R help mailing list archive at Nabble.com. ______________________________________________ R-help@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.