[R] for loop looking for file names

jim holtman jholtman at gmail.com
Wed Dec 3 02:10:57 CET 2008


To get the file names in the current directory try:

list.files(pattern="[[:digit:]]{7}E")

On Tue, Dec 2, 2008 at 4:11 PM, Steven Kennedy <SKennedy at cochlear.com> wrote:
>
> I have a series of csv files in several folders. All begin with a 7 digit
> number and end with the letter "E" (eg. 0726016E.csv).
>
> I want to be able to read a file in to R, take some of the data out of it
> and store it in a matrix, then move on to the next file and do the same
> thing.
>
> I was planning on using a for loop for the digits at the start of the file
> name, but I'm not sure how I can append the letter to the end of the number
> string.
>
> I'm also open to any ideas other than the for loop.
>
> Thanks,
> Steven Kennedy
>
>
> ==============================================
>
> "The information contained in this e-mail message may be confidential information, and may also be privileged. If you are not the intended recipient, any use, interference with, disclosure or copying of this material is unauthorised and prohibited. If you have received this message in error, please notify us by return email and delete the original message."
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem that you are trying to solve?



More information about the R-help mailing list