Skip to content
Prev 68771 / 398506 Next

Reconstruction of a "valid" expression within a function

"Pascal Boisson" <Pascal.Boisson at scri.ac.uk> writes:
No you haven't... You're passing a string to subset(). BTW, it would
be easier to follow your code if it didn't use "subset" with two
different meanings. At the very least you'd need to parse the subset
expression and either eval() it and pass the result to subset(), or
use substitute to insert it at the proper place and eval the whole
enchillada. 

But why? subset() does this stuff internally already:
Ozone Solar.R Wind Temp Month Day
9       8      19 20.1   61     5   9
11      7      NA  6.9   74     5  11
18      6      78 18.4   57     5  18
21      1       8  9.7   59     5  21
23      4      25  9.7   61     5  23
76      7      48 14.3   80     7  15
94      9      24 13.8   81     8   2
114     9      36 14.3   72     8  22
137     9      24 10.9   71     9  14
147     7      49 10.3   69     9  24

[look inside subset.data.frame for the code that accomplishes this]