[R] Using R to create pdf's from each file in a directory

gecko951 ben.lairson at gmail.com
Sat Apr 21 03:40:16 CEST 2007


The Platform I am using R on is RHEL3.  I run a bash script that collects
data into many CSV files and have been processing them one at a time on my
local machine with an excel macro.  I would like to use R to take data
points from each of the CSV files and create line graphs in PDF format
because it will save me ALOT of time.  I am able to successfully do this
when I call the file name directly...however my script bombs when I try to
do multiple files.  I would like the created pdf's to have the same filename
as the original csv files.  I have looked quite a bit and not found much
help on "batch processing" an entire directory.  My current code is as
follows:

list <- dir("/tmp/data")
for(x in list){
d <- read.table(x, sep="\t", header=TRUE) # read data
pdf("/tmp/graph/x.pdf")                              # file for graph
plot(d$BlockSeqNum, d$MBs,                              # Blocks as x, MB/s
as y     
     type="l",                                     # plot lines, not points
     xlab="Blocks",                                  # label x axis
     ylab="MB/s",                                  # label y axis
     main=x)          # add title
dev.off()                                          # close file
q()                                                # quit

ERROR: Error in plot.window(xlim, ylim, log, asp, ...) :
        need finite 'xlim' values
In addition: Warning messages:
1: no non-missing arguments to min; returning Inf
2: no non-missing arguments to max; returning -Inf
3: no non-missing arguments to min; returning Inf
4: no non-missing arguments to max; returning -Inf
Execution halted

Thank you for your wisdom!
-- 
View this message in context: http://www.nabble.com/Using-R-to-create-pdf%27s-from-each-file-in-a-directory-tf3621434.html#a10112832
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list