[R] count data with a specific range

Joris Meys jorismeys at gmail.com
Thu Jun 24 10:36:27 CEST 2010


see ?levels eg:

x <- rnorm(10)
y <- cut(x,c(-10,0,10))
levels(y)<-c("-10-0","0-10")

cheers
Joris

On Thu, Jun 24, 2010 at 4:14 AM, Yi <liuyi.feier at gmail.com> wrote:
> Yeap. It works. Just to make the result more beautiful.
>
> One more question.
>
> The interval is showns as (0,10].
>
> Is there a way to change it into the format 0-10?
> Thanks.
>
> On Wed, Jun 23, 2010 at 6:12 PM, Joris Meys <jorismeys at gmail.com> wrote:
>>
>> see ?cut
>>
>> Cheers
>> Joris
>>
>> On Thu, Jun 24, 2010 at 2:57 AM, Yi <liuyi.feier at gmail.com> wrote:
>> > I would like to prepare the data for barplot. But I only have the data
>> > frame
>> > now.
>> >
>> > x1=rnorm(10,mean=2)
>> > x2=rnorm(20,mean=-1)
>> > x3=rnorm(15,mean=3)
>> > data=data.frame(x1,x2,x3)
>> >
>> > If there a way to put data within a specific range? The expected result
>> > is
>> > as follows:
>> >  range       x1                  x2                    x3
>> > -10-0        2                      5                     1  (# points
>> > in
>> > this range)
>> > 0-10         7                     9                      6
>> > ...
>> >
>> > I know the table function but I do not know how to deal with the range
>> > issue.
>> >
>> > Thanks in advance.
>> >
>> > Yi
>> >
>> >        [[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.
>> >
>>
>>
>>
>> --
>> Joris Meys
>> Statistical consultant
>>
>> Ghent University
>> Faculty of Bioscience Engineering
>> Department of Applied mathematics, biometrics and process control
>>
>> tel : +32 9 264 59 87
>> Joris.Meys at Ugent.be
>> -------------------------------
>> Disclaimer : http://helpdesk.ugent.be/e-maildisclaimer.php
>
>



-- 
Joris Meys
Statistical consultant

Ghent University
Faculty of Bioscience Engineering
Department of Applied mathematics, biometrics and process control

tel : +32 9 264 59 87
Joris.Meys at Ugent.be
-------------------------------
Disclaimer : http://helpdesk.ugent.be/e-maildisclaimer.php



More information about the R-help mailing list