I'm trying to run a function inside a function but get an error message. lst <- list(roots = c("car insurance", "auto insurance"), roots2 = c("insurance"), prefix = c("cheap", "budget"), prefix2 = c("low cost"), suffix = c("quote", "quotes"), suffix2 = c("rate", "rates"), suffix3 = c("comparison"))
myfunc <- function(lst) { myone <- function(x, y) { nu <- do.call(paste, expand.grid(x, y)) mydf <- data.frame(keyword=c(nu)) } mytwo <- function(x, y, z){ mu <- do.call(paste, expand.grid(x, y, z)) mydf2 <- data.frame(keyword=c(mu)) } d1 = mytwo(lst$prefix, lst$roots, lst$suffix) d2 = mytwo(lst$prefix, lst$roots, lst$suffix2) d3 = mytwo(lst$prefix, lst$roots, lst$suffix3) d4 = mytwo(lst$prefix2, lst$roots, lst$suffix) d5 = mytwo(lst$prefix2, lst$roots, lst$suffix2) df = rbind(d1, d2, d3, d4, d5) } I get the following error message: > newdf <- myfunc(lst) Error in expand.grid(x, y) : object 'x' not found Can anyone help! I'm running R 2.13 on Ubuntu 10.10 Abraham [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.