Re: [R] count data with a specific range

From: Joris Meys <jorismeys_at_gmail.com>
Date: Thu, 24 Jun 2010 10:36:27 +0200

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

______________________________________________
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.
Received on Thu 24 Jun 2010 - 08:38:45 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 24 Jun 2010 - 09:30:34 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive