[R] data frame question

Sarah Goslee sarah.goslee at gmail.com
Mon Dec 9 21:45:00 CET 2013


Thank you for providing a reproducible example. I tweaked it a little
bit to make it actually a data frame problem.

There are lots of ways to do this; here's one approach.

On second thought, this looks a lot like homework, so perhaps instead
I'll just suggest using subset() with more than one condition.

Sarah

On Mon, Dec 9, 2013 at 3:27 PM, Andras Farkas <motyocska at yahoo.com> wrote:
> Dear All
>
> please help with the following:
>
> I have:
>
> a <-seq(0,10,by=1)
> b <-c(10:20)
> d <-cbind(a,b)
> f <-16
>
> I would like to select the value in column a based on a value in column b, where the value in column b is the 1st value that is smaller then f. Thus I should end up with the number 5 because the 1st value that is below 16 would be 15, and in the same row column a has the number 5....
>
> appreciate your insights,
>
> andras

-- 
Sarah Goslee
http://www.functionaldiversity.org



More information about the R-help mailing list