[R] Indexing within scan

Justin Rhodes rhodesju at ohsu.edu
Wed Jul 20 00:09:39 CEST 2005


Dear R-help subscribers,

Can some one please help me figure out how to write code that will allow me to use a for loop to scan a number of files one by one, and then save a summary of each file as the for loop progresses.  For example I have 24 files named a1 through a24, and I want to do something like:


results<-numeric(24)
for (i in 1:24)
{
 
p<-scan("ai.txt")  # where the i is an index for each of the 24 files

results[i]<-mean(p)
}

Thanks for any help,





Justin Rhodes
Behavioral Neuroscience
Oregon Health & Science University
VA Medical Center (R & D 12)
3710 SW US Veterans Hospital Rd
Portland, OR  97239
Phone: (503) 220-8262 extn 54392
Fax: (503) 721-1029
E-mail: rhodesju at ohsu.edu




More information about the R-help mailing list