Now that Monday has rolled around I am trying to combine all the victories
of last week.
I have successfully imported my 300+ .xls files into S-Plus data frames,
all of which have names of the form 'stationID' where ID is any number
between 60 and 800. All data frames have the column 'weather.date'
I have successfully written a 'clean.dates' function that will clean the
'weather.date' column of any data frame with the following expression:
stationID$weather.date <- clean.dates(stationID$weather.date)
What I would like to do now is write another function that cleans the
'weather.date' columns for all 300+ data frames, but I cannot see a way to
coerce the data frame names out of the function's parameter.
If I try:
clean.all <- function(id){
frame.name <- paste("station", id, sep="")
as.name(frame.name)$weather.date <-
clean.dates(as.name(frame.name)$weather.date)}
I get the error message: Problem in .A0$weather.date <- .A1: Meaningless to
append to mode "name"
If I try:
clean.all <- function(id){
eval(as.name(paste("station", id, sep="")))$weather.date <-
clean.dates(eval(as.name(paste("station", id,
sep="")))$weather.date)}
I get the error message: Problem in all.dates: Invalid nested assignment:
mode "character", expected name: eval(as.name(paste("station", 67,
sep = "")))$weather.date <- clean.dates(
eval(as.name(paste("station", id, sep = "")))$weather.date)
Unfortunately I have a limited number of tricks up my sleeve and I've run
out. I feel as though there should be a simple way to do this but, once
again, I need further guidance. A little help would go a long way.
Many thanks (again!),
Sarah
______________________________________________
Sarah Henderson
Department of Health Care & Epidemiology
University of British Columbia
Phone: 604.822.1274
Fax: 604.822.9588
Michael Smith Foundation for Health Research Trainee
Canadian Institutes of Health Research Trainee
|