I am trying to write a function:
myfunc <- function(df, out, ...) { # ... = variables in a dataframe
df <- arrange(df, ...) # plyr function that orders rows
out <- df[!duplicated(df[,c(...)]),] # remove duplicates
}
I can't figure out how to get the third line to work. The "..." arguments just need to be converted into a string vector so that the !duplicated() function can work.
I know deparse(substitute(x)) works for 1 argument:
> foo <- function(x) deparse(substitute(x))
> foo(bar)
[1] "bar"
But it doesn't work for multiple arguments. How can I change that so that multiple arguments will work?
> foo <- function(...) deparse(substitute(...))
> foo(bar,goo,poo)
[1] "bar" "goo" "poo"
I would also welcome other solutions that modify the original function (myfunc) if that makes it easier. Thanks.