[R] Assign Name of Data Frame

mah harwood262 at gmail.com
Fri Feb 12 15:19:50 CET 2010


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)



More information about the R-help mailing list