Re: [R] newbie's question about dataframe

From: Wensui Liu <liuwensui_at_gmail.com>
Date: Sat 26 Mar 2005 - 00:38:25 EST

Thank you all for help. Have a nice day.

On Fri, 25 Mar 2005 14:33:16 +0100, Uwe Ligges <ligges@statistik.uni-dortmund.de> wrote:
> Liaw, Andy wrote:
> > Something like this should do it:
> >
> > dat$Z <- with(dat, as.numeric(Y >= Y[order(Y, decreasing=TRUE)[10]]))
>
> I was just about to post
>
> dat$Z <- as.numeric(rank(-dat$Y) <= 10)
>
> so here it is, anyway. ;-)
>
>
> Uwe
>
>
> > Andy
> >
> >
> >>From: Wensui Liu
> >>
> >>I have a dataframe containing X and Y. Right now, I want to create
> >>another variable in the dataframe, named Z, such that for Z = 1 for
> >>the top 10 largest value of Y and Z = 0 for the rest values of Y.
> >>
> >>I really appreciate your help. Have a great weekend.
> >>
> >>______________________________________________
> >>R-help@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
> >>
> >>
> >>
> >
> >
> > ______________________________________________
> > R-help@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
>
>

-- 
WenSui Liu, MS MA
Senior Decision Support Analyst
Division of Health Policy and Clinical Effectiveness
Cincinnati Children Hospital Medical Center

______________________________________________
R-help@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
Received on Sat Mar 26 00:43:59 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:30:56 EST