Re: [Rd] R devel [and R 2.14.1 patched]: R CMD build now sources ~/.Rprofile
I'd like to follow up on this one. It may be that I have misunderstood something, but on both R devel (2012-02-22 r58452) and R 2.14.1 patched (2012-02-18 r58394) I can't seem to avoid loading ~/.Rprofile when I run 'R CMD ', e.g. R CMD build. For me, the loading of ~/.Rprofile by 'R CMD' started a few weeks ago, and I haven't seen it before. More details below. It seems incorrect that for instance 'R CMD check' should load the users ~/.Rprofile file by default. Is this a bug or intended? /Henrik On Wed, Feb 8, 2012 at 5:31 PM, Henrik Bengtsson wrote: > I've just noticed that with a recent R devel on Windows, R CMD build > sources ~/.Rprofile, e.g. > >> RCMD build > Running ~/.Rprofile > >> R CMD build > Running ~/.Rprofile > > FYI R --no-init-file & R --vanilla still avoid this. > >> sessionInfo() > R Under development (unstable) (2012-02-08 r58297) > Platform: x86_64-pc-mingw32/x64 (64-bit) > > locale: > [1] LC_COLLATE=English_United States.1252 > [2] LC_CTYPE=English_United States.1252 > [3] LC_MONETARY=English_United States.1252 > [4] LC_NUMERIC=C > [5] LC_TIME=English_United States.1252 > > attached base packages: > [1] stats graphics grDevices utils datasets methods base >> > > /Henrik __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Silently loading and Depends: versus NAMESPACE imports
On 23.02.2012 06:40, Suraj Gupta wrote: Dirk - I'm having the same issue. Could you provide the details of your solution? By moving the startup message generation to .onAttach? Uwe Ligges On Sat, Jan 28, 2012 at 11:15 AM, Dirk Eddelbuettel wrote: On 28 January 2012 at 16:52, Uwe Ligges wrote: | | | On 27.01.2012 15:57, Dirk Eddelbuettel wrote: |> |> On 12 January 2012 at 12:12, Hervé Pagès wrote: |> | Hi Dirk, |> | |> | On 01/11/2012 11:42 AM, Dirk Eddelbuettel wrote: |> |> |> |> R CMD check really hates it when my .onLoad() function contains |> |>suppressMessages(library(foo)) |> | |> | Note that you can always fool 'R CMD check' by doing something like: |> | |> | sillyname<- library |> | suppressMessages(sillyname("foo")) |> | |> | Also isn't suppressPackageStartupMessages() more appropriate? |> | |> |> |> |> However, _and for non-public packages not going to CRAN_ I prefer doing this |> |> over using explicit Depends or import statements in the NAMESPACE file as the |> |> latter do not give me an ability to make the loading less verbose. With the |> |> R universe of packages being as vast as at is, a simple (non-public) package |> |> I have loads about five or six other packages explicitly, each of which loads |> |> even more. The net result is totally intimidating _sixty lines full_ of |> |> verbose noise that is meaningful to me as an R programmer, but not for the |> |> colleagues expected to use the packages. It looks rather uninviting, frankly. |> |> |> |> How do I use imports via NAMESPACE, and yet keep the noise level down to zero? |> | |> | If you only need to import foo (i.e. and actually don't need to attach |> | it to the search path) then putting foo in Imports and using import |> | statements in NAMESPACE will keep the noise level down to zero. |> |> I don't think so. |> |> I have an internal package, call it fooUtils, that (among other things) needs |> to figure at startup whether it runs on this or that OS. |> |> So that package fooUtils does |> |> .onLoad<- function(libname, pkgname) { |> |> if (.Platform$OS.type == "windows") { |> packageStartupMessage("Running on Windows") |> # [... more stuff here ... ] |> } else if (.Platform$OS.type == "unix") { |> packageStartupMessage("Running on Linux") |> # [... more stuff here ... ] |> } else { |> warning("Platform ", .Platform$OS.type, " not recognised") |> drives<- NULL |> } |> |> # |> |> } | | Are you sure you want the messages in .onLoad rather than .onAttach? Thanks Uwe -- looks like that was exactly the hint I needed. By splitting the task across onLoad and onAttach I seem to be able to get want I need even if the package is "tickled" via NAMESPACE's importFrom. Dirk | See ?.onLoad and its "Good practice" section: | | "Loading a namespace should where possible be silent, with startup | messages given by .onAttach. These messages (and any essential ones from | .onLoad) should use packageStartupMessage so they can be silenced where | they would be a distraction." | | Best, | Uwe | | | |> |> and contrary to your claim, this is not silent as soon as I do |> |> |> importFrom(fooUtils, someThing) |> |> |> the messages above pop up. While I can suppress them for 'normal' loads via |> |> suppressMessages(library(fooUtils)) |> |> or |> |> suppressPackageStartupMessages(library(fooUtils)) |> |> |> I cannot suppress them via NAMESPACE imports. |> |> Dirk |> |> | So I guess your question is: how do we suppress package startup messages |> | for packages listed in Depends? |> | |> | Cheers, |> | H. |> | |> |> |> |> Dirk |> |> |> | |> | |> | -- |> | 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...@fhcrc.org |> | Phone: (206) 667-5791 |> | Fax:(206) 667-1319 |> -- "Outside of a dog, a book is a man's best friend. Inside of a dog, it is too dark to read." -- Groucho Marx __ 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] RcppProgress: progress monitoring and interrupting c++ code, request for comments
Hello, I just created a little package, RcppProgress, to display a progress bar to monitor the execution status of a C++ code loop, possibly multihreaded with OpenMP. I also implemented the possibility to check for user interruption, using the work-around by Simon Urbanek. I just uploaded the package on my R-forge project, so you should be able to get the package from https://r-forge.r-project.org/scm/viewvc.php/pkg/RcppProgress/?root=gwas-bin-tests * The progress bar is displayed using REprintf, so that it works also in the eclipse StatET console, provided that you disable the scroll lock. * You should be able to nicely interrupt the execution by typing CTRL+C in the R console, or by clicking the "cancel current task" in the StatET console. * I tried to write a small documentation, included in the package, but basically you use it like this: The main loop: Progress p(max, display_progress); // create the progress monitor #pragma omp parallel for schedule(dynamic) for (int i = 0; i < max; ++i) { if ( ! p.is_aborted() ) { // the only way to exit an OpenMP loop long_computation(nb); p.increment(); // update the progress } } and in your computation intensive function: void long_computation(int nb) { double sum = 0; for (int i = 0; i < nb; ++i) { if ( Progress::check_abort() ) return; for (int j = 0; j < nb; ++j) { sum += Rf_dlnorm(i+j, 0.0, 1.0, 0); } } } I provided two small R test functions so that you can see how it looks, please see the doc. I would be extremely grateful if you could give me comments, criticisms and other suggestions. I try to release this in order to reuse this functionality in my other packages. Best regards, Karl Forner [[alternative HTML version deleted]] __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] R devel [and R 2.14.1 patched]: R CMD build now sources ~/.Rprofile
I found the following two solutions: ALT 1: R --no-init-file CMD ALT 2: set R_PROFILE_USER="" R CMD As a FYI, it does not work with either of: R CMD --no-init-file R CMD --no-init-file and neither with (Rcmd.exe is special on Windows) Rcmd --no-init-file I've always used Rcmd, so maybe the behavior of 'R CMD' loading ~/.Rprofile has been there longer than I think, but it is only now that 'Rcmd' started to it. /Henrik On Thursday, February 23, 2012, Henrik Bengtsson wrote: > I'd like to follow up on this one. It may be that I have > misunderstood something, but on both R devel (2012-02-22 r58452) and R > 2.14.1 patched (2012-02-18 r58394) I can't seem to avoid loading > ~/.Rprofile when I run 'R CMD ', e.g. R CMD build. For me, the > loading of ~/.Rprofile by 'R CMD' started a few weeks ago, and I > haven't seen it before. More details below. It seems incorrect that > for instance 'R CMD check' should load the users ~/.Rprofile file by > default. Is this a bug or intended? > > /Henrik > > > On Wed, Feb 8, 2012 at 5:31 PM, Henrik Bengtsson > > > wrote: > > I've just noticed that with a recent R devel on Windows, R CMD build > > sources ~/.Rprofile, e.g. > > > >> RCMD build > > Running ~/.Rprofile > > > >> R CMD build > > Running ~/.Rprofile > > > > FYI R --no-init-file & R --vanilla still avoid this. > > > >> sessionInfo() > > R Under development (unstable) (2012-02-08 r58297) > > Platform: x86_64-pc-mingw32/x64 (64-bit) > > > > locale: > > [1] LC_COLLATE=English_United States.1252 > > [2] LC_CTYPE=English_United States.1252 > > [3] LC_MONETARY=English_United States.1252 > > [4] LC_NUMERIC=C > > [5] LC_TIME=English_United States.1252 > > > > attached base packages: > > [1] stats graphics grDevices utils datasets methods base > >> > > > > /Henrik > [[alternative HTML version deleted]] __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Silently loading and Depends: versus NAMESPACE imports
I don't think that is it. My startup message is currently in .onAttach and I still see startup message from packages that I have moved from Imports to Depends. Dirk? 2012/2/23 Uwe Ligges > > > On 23.02.2012 06:40, Suraj Gupta wrote: > >> Dirk - I'm having the same issue. Could you provide the details of your >> solution? >> > > By moving the startup message generation to .onAttach? > > Uwe Ligges > > > > >> On Sat, Jan 28, 2012 at 11:15 AM, Dirk Eddelbuettel >> wrote: >> >> >>> On 28 January 2012 at 16:52, Uwe Ligges wrote: >>> | >>> | >>> | On 27.01.2012 15:57, Dirk Eddelbuettel wrote: >>> |> >>> |> On 12 January 2012 at 12:12, Hervé Pagès wrote: >>> |> | Hi Dirk, >>> |> | >>> |> | On 01/11/2012 11:42 AM, Dirk Eddelbuettel wrote: >>> |> |> >>> |> |> R CMD check really hates it when my .onLoad() function contains >>> |> |>suppressMessages(library(foo)) >>> |> | >>> |> | Note that you can always fool 'R CMD check' by doing something >>> like: >>> |> | >>> |> | sillyname<- library >>> |> | suppressMessages(sillyname("**foo")) >>> |> | >>> |> | Also isn't suppressPackageStartupMessages**() more appropriate? >>> |> | >>> |> |> >>> |> |> However, _and for non-public packages not going to CRAN_ I >>> prefer >>> doing this >>> |> |> over using explicit Depends or import statements in the >>> NAMESPACE >>> file as the >>> |> |> latter do not give me an ability to make the loading less >>> verbose. >>> With the >>> |> |> R universe of packages being as vast as at is, a simple >>> (non-public) package >>> |> |> I have loads about five or six other packages explicitly, each >>> of >>> which loads >>> |> |> even more. The net result is totally intimidating _sixty lines >>> full_ of >>> |> |> verbose noise that is meaningful to me as an R programmer, but >>> not >>> for the >>> |> |> colleagues expected to use the packages. It looks rather >>> uninviting, frankly. >>> |> |> >>> |> |> How do I use imports via NAMESPACE, and yet keep the noise level >>> down to zero? >>> |> | >>> |> | If you only need to import foo (i.e. and actually don't need to >>> attach >>> |> | it to the search path) then putting foo in Imports and using import >>> |> | statements in NAMESPACE will keep the noise level down to zero. >>> |> >>> |> I don't think so. >>> |> >>> |> I have an internal package, call it fooUtils, that (among other >>> things) needs >>> |> to figure at startup whether it runs on this or that OS. >>> |> >>> |> So that package fooUtils does >>> |> >>> |> .onLoad<- function(libname, pkgname) { >>> |> >>> |> if (.Platform$OS.type == "windows") { >>> |> packageStartupMessage("Running on Windows") >>> |> # [... more stuff here ... ] >>> |> } else if (.Platform$OS.type == "unix") { >>> |> packageStartupMessage("Running on Linux") >>> |> # [... more stuff here ... ] >>> |> } else { >>> |> warning("Platform ", .Platform$OS.type, " not >>> recognised") >>> |> drives<- NULL >>> |> } >>> |> >>> |> # >>> |> >>> |> } >>> | >>> | Are you sure you want the messages in .onLoad rather than .onAttach? >>> >>> Thanks Uwe -- looks like that was exactly the hint I needed. >>> >>> By splitting the task across onLoad and onAttach I seem to be able to get >>> want I need even if the package is "tickled" via NAMESPACE's importFrom. >>> >>> Dirk >>> >>> | See ?.onLoad and its "Good practice" section: >>> | >>> | "Loading a namespace should where possible be silent, with startup >>> | messages given by .onAttach. These messages (and any essential ones >>> from >>> | .onLoad) should use packageStartupMessage so they can be silenced where >>> | they would be a distraction." >>> | >>> | Best, >>> | Uwe >>> | >>> | >>> | >>> |> >>> |> and contrary to your claim, this is not silent as soon as I do >>> |> >>> |> >>> |> importFrom(fooUtils, someThing) >>> |> >>> |> >>> |> the messages above pop up. While I can suppress them for 'normal' >>> loads via >>> |> >>> |> suppressMessages(library(**fooUtils)) >>> |> >>> |> or >>> |> >>> |> suppressPackageStartupMessages**(library(fooUtils)) >>> |> >>> |> >>> |> I cannot suppress them via NAMESPACE imports. >>> |> >>> |> Dirk >>> |> >>> |> | So I guess your question is: how do we suppress package startup >>> messages >>> |> | for packages listed in Depends? >>> |> | >>> |> | Cheers, >>> |> | H. >>> |> | >>> |> |> >>> |> |> Dirk >>> |> |> >>> |> | >>> |> | >>> |> | -- >>> |> | 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...@fhcrc.org >>> |> | Phone: (206) 667-5791 >>> |> | Fax:(206) 667-1319 >>> |> >>> >>> -- >>
Re: [Rd] Silently loading and Depends: versus NAMESPACE imports
On 01/28/2012 08:15 AM, Dirk Eddelbuettel wrote: On 28 January 2012 at 16:52, Uwe Ligges wrote: | | | On 27.01.2012 15:57, Dirk Eddelbuettel wrote: |> |> On 12 January 2012 at 12:12, Hervé Pagès wrote: |> | Hi Dirk, |> | |> | On 01/11/2012 11:42 AM, Dirk Eddelbuettel wrote: |> |> |> |> R CMD check really hates it when my .onLoad() function contains |> |>suppressMessages(library(foo)) |> | |> | Note that you can always fool 'R CMD check' by doing something like: |> | |> | sillyname<- library |> | suppressMessages(sillyname("foo")) |> | |> | Also isn't suppressPackageStartupMessages() more appropriate? |> | |> |> |> |> However, _and for non-public packages not going to CRAN_ I prefer doing this |> |> over using explicit Depends or import statements in the NAMESPACE file as the |> |> latter do not give me an ability to make the loading less verbose. With the |> |> R universe of packages being as vast as at is, a simple (non-public) package |> |> I have loads about five or six other packages explicitly, each of which loads |> |> even more. The net result is totally intimidating _sixty lines full_ of |> |> verbose noise that is meaningful to me as an R programmer, but not for the |> |> colleagues expected to use the packages. It looks rather uninviting, frankly. |> |> |> |> How do I use imports via NAMESPACE, and yet keep the noise level down to zero? |> | |> | If you only need to import foo (i.e. and actually don't need to attach |> | it to the search path) then putting foo in Imports and using import |> | statements in NAMESPACE will keep the noise level down to zero. |> |> I don't think so. |> |> I have an internal package, call it fooUtils, that (among other things) needs |> to figure at startup whether it runs on this or that OS. |> |> So that package fooUtils does |> |> .onLoad<- function(libname, pkgname) { |> |> if (.Platform$OS.type == "windows") { |> packageStartupMessage("Running on Windows") |> # [... more stuff here ... ] |> } else if (.Platform$OS.type == "unix") { |> packageStartupMessage("Running on Linux") |> # [... more stuff here ... ] |> } else { |> warning("Platform ", .Platform$OS.type, " not recognised") |> drives<- NULL |> } |> |> # |> |> } | | Are you sure you want the messages in .onLoad rather than .onAttach? Yep. Since in your original post you didn't say that the package you import had its startup message in the wrong place (.onLoad), I assumed it was in the right place (.onAttach). Thanks Uwe -- looks like that was exactly the hint I needed. By splitting the task across onLoad and onAttach I seem to be able to get want I need even if the package is "tickled" via NAMESPACE's importFrom. Are you saying you have some control over the package you import so you could fix it? H. Dirk | See ?.onLoad and its "Good practice" section: | | "Loading a namespace should where possible be silent, with startup | messages given by .onAttach. These messages (and any essential ones from | .onLoad) should use packageStartupMessage so they can be silenced where | they would be a distraction." | | Best, | Uwe | | | |> |> and contrary to your claim, this is not silent as soon as I do |> |> |> importFrom(fooUtils, someThing) |> |> |> the messages above pop up. While I can suppress them for 'normal' loads via |> |> suppressMessages(library(fooUtils)) |> |> or |> |> suppressPackageStartupMessages(library(fooUtils)) |> |> |> I cannot suppress them via NAMESPACE imports. |> |> Dirk |> |> | So I guess your question is: how do we suppress package startup messages |> | for packages listed in Depends? |> | |> | Cheers, |> | H. |> | |> |> |> |> Dirk |> |> |> | |> | |> | -- |> | 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...@fhcrc.org |> | Phone: (206) 667-5791 |> | Fax:(206) 667-1319 |> -- 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...@fhcrc.org Phone: (206) 667-5791 Fax:(206) 667-1319 __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel