[R] Indexing within scan

From: Justin Rhodes <rhodesju_at_ohsu.edu>
Date: Wed 20 Jul 2005 - 08:09:39 EST


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@ohsu.edu



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Wed Jul 20 08:14:37 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:33:50 EST