[R] How to count the nos. in a range?

2012-12-20 Thread Katherine Gobin
Dear R forum I have a following vector of random no.s x = runif(100, 0.01, 0.99)  [1] 0.47212037 0.77867992 0.33947474 0.93369035   [5] 0.03720073 0.79307831 0.81801835 0.92710688 . I need to count the random no. falling in the range (0 -

Re: [R] How to count the nos. in a range?

2012-12-20 Thread Steve Friedman
Have considered cut and table ? On Dec 20, 2012 12:08 PM, Katherine Gobin katherine_go...@yahoo.com wrote: Dear R forum I have a following vector of random no.s x = runif(100, 0.01, 0.99) [1] 0.47212037 0.77867992 0.33947474 0.93369035 [5] 0.03720073 0.79307831 0.81801835 0.92710688

Re: [R] How to count the nos. in a range?

2012-12-20 Thread arun
Hi, Try this: range1-cut(x,breaks=c(0,0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1),labels=paste((,c(0-0.1,0.1-0.2,0.2-0.3,0.3-0.4,0.4-0.5,0.5-0.6,0.6-0.7,0.7-0.8,0.8-0.9,0.9-1),),sep=)) table(range1) #range1  # (0-0.1) (0.1-0.2) (0.2-0.3) (0.3-0.4) (0.4-0.5) (0.5-0.6) (0.6-0.7) (0.7-0.8)    #     8