[R] R function stopped working

DANIEL PRECIADO danprec at hotmail.com
Tue Apr 4 10:50:43 CEST 2017


The following function is supposed to search the workspace and save
plots  (i.e. listing all objects in the workspace named "Figs", which
are all ggplot2 plots, and saving them as png files)

SaveFigs <- function()
{
	for (i in ls(pattern="_Figs_"))
	{
		filename = paste(Plots_Path, i, ".png", sep="")
		png(filename)
		print(eval(as.name(i)))
		dev.off()
	}
}


It was working perfectly until some days ago, but now nothing happens
when the function is called. No error, no output, no result, no files,
nothing at all. Completely useless.

If I run the for loop inside alone, without the function, it works
perfectly and produces the expected result (png files in the defined
folder). But running it as a function doesn't do anything at all.

Can anyone explain why did this function simply and suddenly stopped
working?

(using R version 3.3.3 on an ubuntu 16.10, if that is of any help)


More information about the R-help mailing list