Re: [R] R function stopped working

2017-04-04 Thread Jeff Newmiller
Daniel, if you wish to learn from your mistakes them you must listen. Peter is not someone whose input you should dismiss. The function you have showed us never worked as you have described it. However, if you give .GlobalEnv as the first argument in the call to ls() then it should work. You

Re: [R] R function stopped working

2017-04-04 Thread DANIEL PRECIADO
Thanks! I was not aware of the browser() function, seems pretty useful for debugging. However, for this particular case, adding it to the mentioned function doesn't do much: Again I get no errors, no output in the terminal and no files are created. If I include browser() within the for-loop

Re: [R] R function stopped working

2017-04-04 Thread S Ellison
Maybe a daft question arising from lack of reproducible example, but have you run ls() manually to make sure there are objects that _exactly_ match "_Figs_" ? The simplest explanation for a loop doing nothing is that there are no cases. S Ellison > The following function is supposed to search

Re: [R] R function stopped working

2017-04-04 Thread Boris Steipe
I discourage the use of print() for debugging. Put a browser() statement into your loop and when execution takes you to the debugger interface, examine your variables and expressions one by one. B. > On Apr 4, 2017, at 10:09 AM, DANIEL PRECIADO wrote: > > To your

Re: [R] R function stopped working

2017-04-04 Thread DANIEL PRECIADO
To your first comment: Yes, the function used to work, and the loop inside it still does (as indicated in my first email). I wouldn't bother asking otherwise. To your second, no, specifying the environment in the ls() call doesn't help, the problem persist. On Tue, 2017-04-04 at 15:26 +0200,

Re: [R] R function stopped working

2017-04-04 Thread peter dalgaard
Given the following little experiment > foobar <- 1 > f <- function() ls() > f() character(0) > f <- function(x) ls() > f(2) [1] "x" > ... I am pretty sure that your code _never_ actually worked. It probably helps if you tell ls() which environment to list, as in: > f <- function()

Re: [R] R function stopped working

2017-04-04 Thread DANIEL PRECIADO
Thanks, but printing doesn't work within the function either. (i.e, no result or output, or error). Also, like I said, the loop is working fine on its own (so the path, name, filename, and all other variables called from the function exist, are available and are recognized just fine). It just

Re: [R] R function stopped working

2017-04-04 Thread peter dalgaard
How about inserting print() statements on the output of "ls()" and the value of "filename". In particular, is the value of Plots_path the same as last week? -pd > On 4 Apr 2017, at 10:50 , DANIEL PRECIADO wrote: > > The following function is supposed to search the

[R] R function stopped working

2017-04-04 Thread DANIEL PRECIADO
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 =