[R] Looping through file names and loading...

greggallen at gmail.com greggallen at gmail.com
Wed Apr 15 23:55:50 CEST 2009


Dear R-Community:

I am assisting a community college instructor in an introductory
statistics class.

He has asked me to do this:

Read in a file, of filenames, line by line:

Student_models.txt : (contains 1500+ filenames)
________________________
Experiment_name_student_name_date_time_Model_number_etc_etc
Another_file_name_with_similar_info_as_above
And_another
And_another_one
And_about_1500_more
..........
..........


________________________

function(filename)# I pass in filename
{
for(i in 1:length(filename))
{
s <-  filename[i,1]
print(s) # I check the file name, and it is OK.
load(s) # This returns all sorts of errors, most common is: object
"mod" not found.
..................
pred <- predict( s , test_vector) # I never get this far
print(pred)

write(filename, pred, "output.txt")

.....

}

The filenames are correct, and I can use "load(s)"  interactively, but
it won't work in a function.

Thanks for ANY help!!!!

Gregg Allen
USA




More information about the R-help mailing list