[R] how to read a file containing a series filename
jholtman at gmail.com
Wed Mar 7 15:28:49 CET 2012
This works fine for me; look at your options on 'scan':
> x <- scan(text = "H20100902.TXT
+ H20100908.TXT", what = '')
Read 7 items
> cat(x, file = 'file.txt', sep = '\n') # create the 'file.txt'
> files <- scan('file.txt', what = '') # read names from the file
Read 7 items
> files # display the names
 "H20100902.TXT" "H20100903.TXT" "H20100904.TXT" "H20100905.TXT"
 "H20100907.TXT" "H20100908.TXT"
On Wed, Mar 7, 2012 at 8:49 AM, Jie Tang <totangjie at gmail.com> wrote:
> hi everyone .
> I have a group of files that needs to be read in .
> And I put their filename into one file with the name "file.txt"
> And in the file.txt,the filename are shown as below :
> Now I want to read these file from the file.txt by such codes:
> filename <-("file.txt")
> pp <- scan(filename,what=list(""),sep=" ")
> but R shows that :
> that is pp is just one dimension data?
> but when I type
> the filenames are shown.
> How could I read these filenames into one array
> and so that .I can read the data by such a command ?
> ddata<-scan(pp,what=datalist,na.strings = 999)
> thank you .
> TANG Jie
> Email: totangjie at gmail.com
> Tel: 0086-2154896104
> Shanghai Typhoon Institute,China
> [[alternative HTML version deleted]]
> R-help at r-project.org mailing list
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
Data Munger Guru
What is the problem that you are trying to solve?
Tell me what you want to do, not how you want to do it.
More information about the R-help