R data frame select by global variable

Posted by Matt on Stack Overflow See other posts from Stack Overflow or by Matt
Published on 2010-04-03T19:06:07Z Indexed on 2010/04/03 19:13 UTC
Read the original article Hit count: 234

Filed under:
|
|

I'm not sure how to do this without getting an error. Here is a simplified example of my problem.

Say I have this data frame DF

a   b  c  d
1   2  3  4
2   3  4  5
3   4  5  6

Then I have a variable

x <- min(c(1,2,3))

Now I want do do the following

y <- DF[a == x]

But when I try to refer to some variable like "x" I get an error because R is looking for a column "x" in my data frame. I get the "undefined columns selected" error

How can I do what I am trying to do in R?

© Stack Overflow or respective owner

Related posts about r

    Related posts about global-variables