Confused about quote(), call(), etc.

15 views
Skip to first unread message

Stuart Luppescu

unread,
Sep 6, 2016, 10:08:03 PM9/6/16
to manip...@googlegroups.com
Hello, I'm trying to construct a string to use in a filter() call, based on other parameters. I did something like this:

cut <- 2
wh.fit <- "b"
group <- "m"
min.resp <- 2

if(group=="m") {
    if(wh.fit=="i") {
        fit.filter <- quote(in.msq > cut)
    } else if (wh.fit=="o") {
        fit.filter <- quote(out.msq > cut)
    } else if (wh.fit=="b") {
        fit.filter <- quote(in.msq > cut | out.msq > cut)
    }
} else if (group=="o") {
    if(wh.fit=="i") {
        fit.filter <- quote(in.msq < 1/cut)
...

Then after I'm done with the fit.filter, I want to prepend this string:
"count >= min.resp & "

So, in the above example, fit.filter would be "in.msq > cut | out.msq > cut".
Then I want to concatenate the two and make a single string I can put inside of filter(), like this:

filter(., count >= min.resp & in.msq > cut | out.msq > cut)

  but I can't figure out how to do it. I tried all kinds of combinations of paste(), quote(), call(), eval() but can't get it to work. 

I know I can just add that string "count >= min.resp & " to each of the quote() calls above, but that seems inefficient and inelegant to me.

Thanks in advance for any help.
--
 
Stuart Luppescu -- pixbuf .at. gmail.com
I made up a new word: plagiarism.
  --jpuller
Reply all
Reply to author
Forward
0 new messages