[R] Writing a .pdf file within a function - what do I need to return()?

Dgnn sharkbrainpdx at gmail.com
Tue Mar 13 20:55:39 CET 2012

I am trying to write a function that generates one PDf containing plots from
several .csv files within a directory.  When I manually execute the code it
seems to work, but not when it is a function. I think I need to return()
something, but haven't had much luck figuring out what/how.

plot.isi<-function(csv.path="~/project/csv by cell") { 
	csv.files<-grep('.csv', list.files(path = csv.path, full.names=T), value=T)
	pdf(file='plots/isi plots.pdf', width=10, height=8)
	#par(mfrow=c(2,1)) #ideally 2 plots per page, but will work on details
after fx. works
	for (i in 1:length(csv.files)){
		xyplot(isi ~ t, raw.df, ylim=c(0,1500), ylab='isi', xlab='time', 

Thank you all for the help,

Jason Deignan

View this message in context: http://r.789695.n4.nabble.com/Writing-a-pdf-file-within-a-function-what-do-I-need-to-return-tp4470165p4470165.html
Sent from the R help mailing list archive at Nabble.com.

More information about the R-help mailing list