Nhan Vu Lam Chi
2013-May-14 01:38 UTC
[R] How to capture the expression corresponding to the i param in the [ function
Hi everyone, I currently work on a S4 class that has the [ function. I want to capture the unevaluated expression corresponding to the i param using substitute() function and do a non-standard evaluation. However R automatically evaluates the expression and give me its value. For example: Given mydf[mydf$V1 > 1,] with mydf is an object of my custom S4 dataframe class and V1 is one of its columns, I want to get the unevaluated expression mydf$V1 > 1. My questions are: 1. Is it possible to do that in R? 2. If yes, how to do? My R version and OS info are: R version 2.15.3 (2013-03-01) -- "Security Blanket" Copyright (C) 2013 The R Foundation for Statistical Computing ISBN 3-900051-07-0 Platform: x86_64-pc-linux-gnu (64-bit) This is the first time I post to the mailing list, so please forgive any mistakes and/or advise me if possible. Regards, Nhan Vu [[alternative HTML version deleted]]
David Winsemius
2013-May-14 05:14 UTC
[R] How to capture the expression corresponding to the i param in the [ function
On May 13, 2013, at 6:38 PM, Nhan Vu Lam Chi wrote:> Hi everyone, > I currently work on a S4 class that has the [ function. I want to capture > the unevaluated expression corresponding to the i param using substitute() > function and do a non-standard evaluation. However R automatically > evaluates the expression and give me its value. > For example: > Given mydf[mydf$V1 > 1,] with mydf is an object of my custom S4 dataframe > class and V1 is one of its columns, I want to get the unevaluated > expression mydf$V1 > 1. > > My questions are: > 1. Is it possible to do that in R? > 2. If yes, how to do?Doesn't this cry out for the S4 class definition of "[" to be answerable?. Because "[" is generic, it could have almost any definition at the whim of the package author.> My R version and OS info are: > R version 2.15.3 (2013-03-01) -- "Security Blanket" > Copyright (C) 2013 The R Foundation for Statistical Computing > ISBN 3-900051-07-0 > Platform: x86_64-pc-linux-gnu (64-bit) > > This is the first time I post to the mailing list, so please forgive any > mistakes and/or advise me if possible. > Regards, > Nhan Vu > > [[alternative HTML version deleted]]You are forgiven, but this once, for posting in HTML. -- David Winsemius Alameda, CA, USA