This is fairly straight forward, you can do something like:

myfiles <- scan('files.txt', what="")
base <- sub("\\.[^.]*$", "", myfiles)

lapply( seq_along(myfiles), function(i) {
    mydat <- read.table( myfiles[i] )
    sink( sprintf('%sSummary.txt', base[i]) )
    summary(mydat)
    sink()
    bmp( sprintf("%sPlot.bmp", base[i]) )
    with(mydat, plot(x,y))
    dev.off()
} )

Of course modifying things to include what you want to use.  If you want
the summary information and plots together in a single output file (pdf
file, word document, html, etc.) then you should look at the knitr package
as a way to set up a template and possibly the pandoc program as a way to
convert the results to another format, then do the processing in a loop
like above.




On Tue, Jan 15, 2013 at 5:30 AM, Simonas Kecorius <simolas2...@gmail.com>wrote:

> Dear R users,
>
> First of all I would like to thank all of you who replayed to my previous
> questions and problems. Thank you a lot for being great and helpful
> community. I highly appreciate your suggestions and ideas even if I do not
> respond after my question! But it means that your help was exactly what I
> needed. Thank you again!
>
> Now the following question I need help:
>
> Suppose I do have a file.txt in the working directory. This file contains
> the names of other files in the same directory:
>
> First.txt
> Second.txt
> Third.txt
> etc...
>
> Files First.txt, Second.txt...are data files.
>
> What I need R to do, is to read this file.txt line by line, open files
> which names are listed ( First.txt, Second.txt...) and process it: lets say
> make a FirstPlot.bmp, FirstSummary.txt  and save it to working directory,
> then automatically open Second.txt, do the same, Third.txt etc. until the
> end of the names in file.txt.
>
> This would help me with the following task: I do measurements each day, and
> I need to process my data: draw some plots, make some analysis.  When I
> have 30 days of measurements each 1 second, there are huge amount of
> numbers I am dealing with. If you could suggest some automation via R, it
> would be perfect.
>
> Thank you in advance.
>
> Cheers.
>
> --
> Simonas Kecorius
> **Lithuania
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help@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.
>



-- 
Gregory (Greg) L. Snow Ph.D.
538...@gmail.com

        [[alternative HTML version deleted]]

______________________________________________
R-help@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.

Reply via email to