You also posted this on stackoverflow ( http://stackoverflow.com/questions/10675182/in-r-data-table-how-do-i-pass-variable-parameters-to-an-expression), so there is no need to post it here as well. I think the answers there are already helpful.
On Sun, May 20, 2012 at 6:34 PM, Jitender <[email protected]> wrote: > I am stuck with a small R issue with data.table. Your help is much > appreciated. How do I do this: > > get <- function(dt, expr, gby) { > > > e <- substitute(expr) > > > b <- substitute(gby) > > > return(dt[,eval(e),by=b]) > > } > > > v1 <- "Sepal.Length" > > > v2 <- "Species" > > > dt <- data.table(iris) > > > rDT <- get(dt, sum(v1, na.rm=TRUE), v2) > > I get following error: Error in sum(v1, na.rm = TRUE) : invalid 'type' > (character) of argument > > Now, both v1 and v2 get passed from other program as character variable so > I can't do this v1<- quote(Sepal.Length) which seems to work. > > _______________________________________________ > datatable-help mailing list > [email protected] > https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/datatable-help >
_______________________________________________ datatable-help mailing list [email protected] https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/datatable-help
