[Rd] using with inside loop breaks next
If I want to use with inside a loop, it seems that next gets confused. To reproduce: for(lst in list(list(a = 1), list(a = 2), list(a = 3))) { with(lst, if(a == 2) next else print(a)) } I expect 1 and 3 to be printed, but I see [1] 1 Error in eval(expr, envir, enclos) : no loop for break/next, jumping to top level Is this a) by design, or b) a bug, or c) a thing that is rare enough that I should just rewrite my code? -- Regards, Richie Learning R 4dpiecharts.com __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] improve 'package not installed' load errors?
> A side question, which I do not know the answer to, is how users get > themselves into this state. I've fallen over this a few times. It happens when you have multiple R sessions running, and R tries to update Rcpp while it is loaded in the other session. For example, I'm working on one project, then I open another copy of R to work on a different project. Because I have update.packages in my Rprofile, R occasionally tries to update Rcpp. If that is loaded in the first session, then a clean uninstall doesn't happen (the directory and the dll are left). Since the directory is still there, update.packages thinks that the package exists, and I'm left with a mangled copy of Rcpp that I need to manually remove. On 24 October 2016 at 20:51, Kevin Ushey wrote: > Hi R-devel, > > One of the more common issues that new R users see, and become stumped > by, is error messages during package load of the form: > >> library(ggplot2) > Error in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), > versionCheck = vI[[j]]) : > there is no package called 'Rcpp' > Error: package or namespace load failed for 'ggplot2' > > Typically, error messages of this form are caused simply by one or > more dependent packages (in this case, 'Rcpp') not being installed or > available on the current library paths. (A side question, which I do > not know the answer to, is how users get themselves into this state.) > > I believe it would be helpful for new users if the error message > reported here was a bit more direct, e.g. > >> library(ggplot2) > Error: 'ggplot2' depends on package 'Rcpp', but 'Rcpp' is not installed > consider installing 'Rcpp' with install.packages("Rcpp") > > In other words, it might be helpful to avoid printing the > 'loadNamespace()' call on error (since it's mostly just scary / > uninformative), and check up-front that the package is installed > before attempting to call 'loadNamespace()'. I'm sure a number of > novice users will still just throw their hands up in the air and say > "I don't know what to do", but I think this would help steer a number > of users in the right direction. > > (The prescription to suggest installing a package from CRAN if > available might be a step too far, but I think making it more clear > that the error is due to a missing dependent package would help.) > > Any thoughts? > Kevin > > __ > R-devel@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-devel -- Regards, Richie Learning R 4dpiecharts.com __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] using with inside loop breaks next
(a)/(c) mostly, I think. The crux is that "next" is unhappy about being evaluated in a different environment than the containing loop. Witness this: > for (i in 1:10) {if (i == 5) evalq(next); print(i)} [1] 1 [1] 2 [1] 3 [1] 4 [1] 6 [1] 7 [1] 8 [1] 9 [1] 10 > for (i in 1:10) {if (i == 5) evalq(next, new.env()); print(i)} [1] 1 [1] 2 [1] 3 [1] 4 Error in eval(substitute(expr), envir, enclos) : no loop for break/next, jumping to top level > for (i in 1:10) {if (i == 5) evalq(next, parent.env(new.env())); print(i)} [1] 1 [1] 2 [1] 3 [1] 4 [1] 6 [1] 7 [1] 8 [1] 9 [1] 10 -pd > On 27 Oct 2016, at 09:51 , Richard Cotton wrote: > > If I want to use with inside a loop, it seems that next gets confused. > To reproduce: > > for(lst in list(list(a = 1), list(a = 2), list(a = 3))) > { > with(lst, if(a == 2) next else print(a)) > } > > I expect 1 and 3 to be printed, but I see > > [1] 1 > Error in eval(expr, envir, enclos) : > no loop for break/next, jumping to top level > > Is this > a) by design, or > b) a bug, or > c) a thing that is rare enough that I should just rewrite my code? > > -- > Regards, > Richie > > Learning R > 4dpiecharts.com > > __ > R-devel@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-devel __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] enhancement to R CMD check: do imported objects from multiple packages mask each other?
Dear R-Developement Team, I want to suggest an additiol check to the R CMD check functionality. Consider the situation where the objects of more than one package are imported to the NAMESPACE of a third package, e.g. via import(foo, bar) in the NAMESPACE file. There might be situations where exported objects in the packages `foo` and `bar` have the same name, let´s say there is an object `f` exported from both packages. Then a warning created by R CMD check comparable to the same situation when attaching multiple packages to the search path, like > library(foo) > library(bar) The following objects are masked from ‘package:foo’: f would be very helpful. I am aware that it is not best practice to import many packages with many exported objects to the NAMESPACE of another package. Nevertheless it would be nice feature to be warned about the resulting name conflict. Thanks in advance. Steffen -- INWT Statistics GmbH Obentrautstraße 72 10963 Berlin Fon +49 30 609857995 Fax +49 30 609857998 E-Mail steffen.wag...@inwt-statistics.de www.inwt-statistics.de Sitz der Gesellschaft: Berlin-Kreuzberg AG Berlin-Charlottenburg, HRB 133141 B Geschäftsführer: Dr. Amit Ghosh __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] enhancement to R CMD check: do imported objects from multiple packages mask each other?
On 27/10/2016 5:26 AM, Steffen Wagner wrote: Dear R-Developement Team, I want to suggest an additiol check to the R CMD check functionality. Consider the situation where the objects of more than one package are imported to the NAMESPACE of a third package, e.g. via import(foo, bar) in the NAMESPACE file. There might be situations where exported objects in the packages `foo` and `bar` have the same name, let´s say there is an object `f` exported from both packages. Then a warning created by R CMD check comparable to the same situation when attaching multiple packages to the search path, like > library(foo) > library(bar) The following objects are masked from ‘package:foo’: f would be very helpful. I am aware that it is not best practice to import many packages with many exported objects to the NAMESPACE of another package. Nevertheless it would be nice feature to be warned about the resulting name conflict. That sounds like a reasonable suggestion. However, unless someone volunteers to do it very quickly, it will likely get lost in the archives of this list and forgotten. Could you please post it to the bug list as an enhancement request? Those should be persistent. If you have never posted to the bug list you will need to be manually added to the list of people allowed to post. In that case, write to me and I'll do it. Duncan Murdoch __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] enhancement to R CMD check: do imported objects from multiple packages mask each other?
Hi Duncan, On 10/27/2016 05:17 AM, Duncan Murdoch wrote: [...] Could you please post it to the bug list as an enhancement request? Those should be persistent. If you have never posted to the bug list you will need to be manually added to the list of people allowed to post. In that case, write to me and I'll do it. Sorry to ask such a naive question but is there a bug list or do you mean the Bugzilla bug tracker? Thanks, H. -- Hervé Pagès Program in Computational Biology Division of Public Health Sciences Fred Hutchinson Cancer Research Center 1100 Fairview Ave. N, M1-B514 P.O. Box 19024 Seattle, WA 98109-1024 E-mail: hpa...@fredhutch.org Phone: (206) 667-5791 Fax:(206) 667-1319 __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] BUG?: On Linux setTimeLimit() fails to propagate timeout error when it occurs (works on Windows)
On unix, unless event polling is enabled Sys.sleep just waits in a select() call (with a SIGINT handler in place) so the elapsed time isn't checked until after the select call is complete. Rstudio uses event polling, and in particular sets R_wait_usec to 1, which means event and interrupt checks happen during a Sys.seep call. The R GUI on macOS doesn't seem to do this (but my lldb skills aren't up to checking). Now that we have this elapsed time limit mechanism it might be a good idea to set the default for R_wait_usec to something reasonable on unix in general. 10 might be a good value. A more worrying thing I noticed while looking at this is that blocking reads on fifos and pipes and probably sockets are not interruptable -- that should probably be looked into. Best, luke On Wed, 26 Oct 2016, peter dalgaard wrote: Spencer also had tools and rsconnect loaded (via a namespace) but it doesn't seem to make a difference for me if I load them. It also doesn't seem to matter for me whether it is CRAN R, locally built R, Terminal, R.app. However, RStudio differs setTimeLimit(elapsed=1) Error: reached elapsed time limit setTimeLimit(elapsed=1) Error: reached elapsed time limit setTimeLimit(elapsed=1); system.time({Sys.sleep(10);message("done")}) Error in Sys.sleep(10) : reached elapsed time limit Timing stopped at: 0.003 0.003 0.733 -pd On 26 Oct 2016, at 21:54 , Henrik Bengtsson wrote: Thank you for the feedback and confirmations. Interesting to see that it's also reproducible on macOS expect for Spencer; that might indicate a difference in builds. BTW, my original post suggested that timeout error was for sure detected while running Sys.sleep(10). However, it could of course also be that it is only detected after it finishes. For troubleshooting, the help("setTimeLimit", package = "base") says that: * "Time limits are checked whenever a user interrupt could occur. This will happen frequently in R code and during Sys.sleep, but only at points in compiled C and Fortran code identified by the code author." The example here uses Sys.sleep(), which supports and detects user interrupts. The timeout error message is thrown by the R_ProcessEvents(void) function as defined in: * src/unix/sys-unix.c (https://github.com/wch/r-source/blob/trunk/src/unix/sys-unix.c#L421-L453) * src/gnuwin32/system.c (https://github.com/wch/r-source/blob/trunk/src/gnuwin32/system.c#L110-L140) So, they're clearly different implementations on Windows and Unix. Also, for the Unix implementation, the code differ based on preprocessing directive HAVE_AQUA, which could explain why Spencer observes a different behavior than Peter and Berend (all on macOS). Whenever the R_CheckUserInterrupt() function is called it in turn always calls R_ProcessEvents(). At the end, there is a code snippet - if (R_interrupts_pending) onintr(); - which is Windows specific and could be another important difference between Windows and Unix. This function is defined in: * src/main/errors.c (https://github.com/wch/r-source/blob/trunk/src/main/errors.c#L114-L134) The do_setTimeLimit() function controls global variables cpuLimitValue and elapsedLimitValue, which are checked in R_ProcessEvents(), but other than setting the timeout limits I don't think it's involved in the runtime checks. The do_setTimeLimit() is defined in: * src/main/sysutils.c (https://github.com/wch/r-source/blob/trunk/src/main/sysutils.c#L1692-L1736) Unfortunately, right now, I've got little extra time to troubleshoot this further. /Henrik On Wed, Oct 26, 2016 at 2:22 AM, Berend Hasselman wrote: On 26 Oct 2016, at 04:44, Henrik Bengtsson wrote: ... This looks like a bug to me. Can anyone on macOS confirm whether this is also a problem there or not? Tried it on macOS El Capitan and got this (running in R.app with R version 3.3.2 RC (2016-10-23 r71574): setTimeLimit(elapsed=1) system.time({ Sys.sleep(10); message("done") }) Error in Sys.sleep(10) : reached elapsed time limit Timing stopped at: 0.113 0.042 10.038 Berend __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel -- Luke Tierney Ralph E. Wareham Professor of Mathematical Sciences University of Iowa Phone: 319-335-3386 Department of Statistics andFax: 319-335-3017 Actuarial Science 241 Schaeffer Hall email: luke-tier...@uiowa.edu Iowa City, IA 52242 WWW: http://www.stat.uiowa.edu __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] enhancement to R CMD check: do imported objects from multiple packages mask each other?
On 27/10/2016 11:58 AM, Hervé Pagès wrote: Hi Duncan, On 10/27/2016 05:17 AM, Duncan Murdoch wrote: [...] > Could you please post it to the bug list as an enhancement request? > Those should be persistent. > > If you have never posted to the bug list you will need to be manually > added to the list of people allowed to post. In that case, write to me > and I'll do it. Sorry to ask such a naive question but is there a bug list or do you mean the Bugzilla bug tracker? I meant bugzilla. Duncan Murdoch __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel