[R] factors and ops

Gabor Grothendieck ggrothendieck at gmail.com
Fri May 26 10:54:12 CEST 2006


Try an ordered factor:

  subset(HR, ordered(Patient) > 214)

or

  HR$Patient <- ordered(HR$Patient)
  subset(HR, Patient > 214)

You might also check that it orders them in the way you want.
ordered(HR$Patient) in the first case or just HR$Patient in the
second case will display the data followed by the ordering.

On 5/26/06, Erin Hodgess <hodgess at gator.dt.uh.edu> wrote:
> Dear R People
>
> I have a variable which is an ID number that is a factor.
>
> I would like to look for ID numberbs that are greeater than
> a particular value.
>
> However, factors are a big ugly for these operations.
>
> I was messing with the HR data set from the SASmixed package.
>
> HR$Patient is a factor like that.
>
> Now if I used:
> subset(HR,as.integer(as.character(Patient)) > 214)
>
> that will work.
>
> If seems to me that there may be a better way.
> Is that true?
>
> R Version 2.3.0 Windows
>
> Thanks in advance!
>
>
> sincerely,
> Erin Hodgess
> Associate Professor
> Department of Computer and Mathematical Sciences
> University of Houston - Downtown
> mailto: hodgess at gator.uhd.edu
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>



More information about the R-help mailing list