Hello R Experts, How can I assign the name of a data frame with the argument of a function? Specifically I am using RODBC to build local dataframes from SAS datasets on a remote server. I would like the local dataframe have the same name as the source SAS dataset, and the function below is what I am developing. However, the "substitute(table)" on the left side of the assignment generates the error "Error in substitute(table) <<- sqlQuery(sears, sql.stmt) : could not find function "substitute<-".
Thanks in advance MakeDF <- function(table) #------------------------------------------------------------ # Function makes dataframe from UNIX SAS datasets #------------------------------------------------------------ { st.time <- Sys.time() print(substitute(table)) sql.stmt <- paste("select * from swprod.", substitute(table), sep="") print(sql.stmt) substitute(table) <<- sqlQuery(sears, sql.stmt) # deparse(substitute(table)) <<- sqlQuery(sears, sql.stmt) end.time print(end.time - st.time) } MakeDF(sku_series) ______________________________________________ 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.