[R-pkg-devel] Proper way to ask a user to set permanent variables?

2020-01-14 Thread Jonathan Greenberg
Folks:

My package gdalUtils is a wrapper for a set of binaries on disk (the GDAL 
Utilities) -- these have about as many places to install as there are people 
installing it, and the system environment variables aren't always much help 
(they aren't always set) for locating them.  My package is trying to 
dummy-proof the usage as much as possible, so one of the things it does is if 
it can't find the install, it goes search for the install in, first, standard 
locations and runs a short test to see if the install is valid and, if not, 
goes on a longer hunt.  Right now, it does this search everytime someone boots 
up R and uses it, which slows down the process.

What I'm wondering is twofold:

1) Are there any packages/methods by which user "preferences" are saved that 
don't require saving workspaces (e.g. does R have a standardized "preferences" 
location that packages can use).

2) If the answer to #1 is "no", what is the preferred method for saving 
variables for use by packages that are always restored on boot -- e.g. I was 
thinking something like .Renviron but I think that's Rstudio only.  I'm 
concerned with workspace-type saves since I feel like that often results in a 
ton of variables being saved.

Thanks!

--j

[[alternative HTML version deleted]]

__
R-package-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-package-devel


Re: [R-pkg-devel] Proper way to ask a user to set permanent variables?

2020-01-14 Thread Duncan Murdoch

On 14/01/2020 11:06 a.m., Jonathan Greenberg wrote:

Folks:

My package gdalUtils is a wrapper for a set of binaries on disk (the GDAL 
Utilities) -- these have about as many places to install as there are people 
installing it, and the system environment variables aren't always much help 
(they aren't always set) for locating them.  My package is trying to 
dummy-proof the usage as much as possible, so one of the things it does is if 
it can't find the install, it goes search for the install in, first, standard 
locations and runs a short test to see if the install is valid and, if not, 
goes on a longer hunt.  Right now, it does this search everytime someone boots 
up R and uses it, which slows down the process.

What I'm wondering is twofold:

1) Are there any packages/methods by which user "preferences" are saved that don't 
require saving workspaces (e.g. does R have a standardized "preferences" location that 
packages can use).

2) If the answer to #1 is "no", what is the preferred method for saving 
variables for use by packages that are always restored on boot -- e.g. I was thinking 
something like .Renviron but I think that's Rstudio only.  I'm concerned with 
workspace-type saves since I feel like that often results in a ton of variables being 
saved.


You can read ?Startup to see what happens when R starts up.  Putting 
environment variables in .Renviron would work; so would putting R code 
in .Rprofile.  However, those files both belong to the user, so your 
package shouldn't write to them without asking, and it's probably better 
not to write there at all.


A few packages put cached information into a ~/.R directory; I'd suggest 
putting your stuff into ~/.R/gdaUtils/* (after asking for permission).


Duncan Murdoch

__
R-package-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-package-devel


[R-pkg-devel] seeking help regarding the valgrind error

2020-01-14 Thread Yang Feng
Hi All,

Happy new year! I just joined this mailing list and would like to post my
first question.

I received a message earlier this month regarding an error in my R package
RAMP https://cran.r-project.org/web/packages/RAMP/index.html
I need to update the package by the end of this month to prevent it from
removed from CRAN.

The detailed email message is as follows. Does anyone know how to fix this?
Also, how to reproduce this kind of error on my local mac?

Many thanks!


Checking with valgrind shows:

Still

 > fit1 = RAMP(x, y)
==4663== Invalid read of size 8
==4663==at 0x48A0A51: cd_general_lin_
(/tmp/RAMP.Rcheck/00_pkg_src/RAMP/src/cd_general_lin.f:21)
==4663==by 0x49DDE6: do_dotCode (svn/R-devel/src/main/dotcode.c:1799)
==4663==by 0x4D181C: bcEval (svn/R-devel/src/main/eval.c:7054)
==4663==by 0x4E8197: Rf_eval (svn/R-devel/src/main/eval.c:688)
==4663==by 0x4E9D56: R_execClosure (svn/R-devel/src/main/eval.c:1853)
==4663==by 0x4EAB33: Rf_applyClosure (svn/R-devel/src/main/eval.c:1779)
==4663==by 0x4DB64D: bcEval (svn/R-devel/src/main/eval.c:7022)
==4663==by 0x4E8197: Rf_eval (svn/R-devel/src/main/eval.c:688)
==4663==by 0x4E9D56: R_execClosure (svn/R-devel/src/main/eval.c:1853)
==4663==by 0x4EAB33: Rf_applyClosure (svn/R-devel/src/main/eval.c:1779)
==4663==by 0x4E8363: Rf_eval (svn/R-devel/src/main/eval.c:811)
==4663==by 0x4ECD01: do_set (svn/R-devel/src/main/eval.c:2920)
==4663==  Address 0x1616c100 is 7,600 bytes inside a block of size 7,960
alloc'd
==4663==at 0x483880B: malloc
(/builddir/build/BUILD/valgrind-3.15.0/coregrind/m_replacemalloc/vg_replace_malloc.c:309)
==4663==by 0x5223E0: GetNewPage (svn/R-devel/src/main/memory.c:946)

Please fix and resubmit.

Best wishes,
Yang

[[alternative HTML version deleted]]

__
R-package-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-package-devel


Re: [R-pkg-devel] Proper way to ask a user to set permanent variables?

2020-01-14 Thread Gábor Csárdi
You can use the rappdirs package to look up the standard places for
permanent config, cache etc. files. E.g. on macOS:

❯ rappdirs::user_cache_dir()
[1] "/Users/gaborcsardi/Library/Caches"

Gabor

On Tue, Jan 14, 2020 at 4:10 PM Jonathan Greenberg  wrote:
>
> Folks:
>
> My package gdalUtils is a wrapper for a set of binaries on disk (the GDAL 
> Utilities) -- these have about as many places to install as there are people 
> installing it, and the system environment variables aren't always much help 
> (they aren't always set) for locating them.  My package is trying to 
> dummy-proof the usage as much as possible, so one of the things it does is if 
> it can't find the install, it goes search for the install in, first, standard 
> locations and runs a short test to see if the install is valid and, if not, 
> goes on a longer hunt.  Right now, it does this search everytime someone 
> boots up R and uses it, which slows down the process.
>
> What I'm wondering is twofold:
>
> 1) Are there any packages/methods by which user "preferences" are saved that 
> don't require saving workspaces (e.g. does R have a standardized 
> "preferences" location that packages can use).
>
> 2) If the answer to #1 is "no", what is the preferred method for saving 
> variables for use by packages that are always restored on boot -- e.g. I was 
> thinking something like .Renviron but I think that's Rstudio only.  I'm 
> concerned with workspace-type saves since I feel like that often results in a 
> ton of variables being saved.
>
> Thanks!
>
> --j
>
> [[alternative HTML version deleted]]
>
> __
> R-package-devel@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-package-devel

__
R-package-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-package-devel


Re: [R-pkg-devel] seeking help regarding the valgrind error

2020-01-14 Thread Serguei Sokol

Hi Yang,

Le 14/01/2020 à 17:29, Yang Feng a écrit :

Hi All,

Happy new year! I just joined this mailing list and would like to post my
first question.

I received a message earlier this month regarding an error in my R package
RAMP https://cran.r-project.org/web/packages/RAMP/index.html
I need to update the package by the end of this month to prevent it from
removed from CRAN.

The detailed email message is as follows. Does anyone know how to fix this?
Yep. The default value for gamma parameter in RAMP is NULL. So when you 
do in cd.general.R:


para.in = c(epsilon, max.iter, lambda, gamma)

and later on in .Fortran() call

..., paraIn = as.double(para.in) ...

you obtain a vector of length 3 while it is expected to be of length 4 
in cd_general_lin.f:


double precision, dimension(4) :: paraIn

So that when you read the 4-th element on line 21:

gamma = paraIn(4)

you are caught by valgrid.

Fixing that is left as exercise ;)

Best,
Serguei.



Also, how to reproduce this kind of error on my local mac?

Many thanks!


Checking with valgrind shows:

Still

  > fit1 = RAMP(x, y)
==4663== Invalid read of size 8
==4663==at 0x48A0A51: cd_general_lin_
(/tmp/RAMP.Rcheck/00_pkg_src/RAMP/src/cd_general_lin.f:21)
==4663==by 0x49DDE6: do_dotCode (svn/R-devel/src/main/dotcode.c:1799)
==4663==by 0x4D181C: bcEval (svn/R-devel/src/main/eval.c:7054)
==4663==by 0x4E8197: Rf_eval (svn/R-devel/src/main/eval.c:688)
==4663==by 0x4E9D56: R_execClosure (svn/R-devel/src/main/eval.c:1853)
==4663==by 0x4EAB33: Rf_applyClosure (svn/R-devel/src/main/eval.c:1779)
==4663==by 0x4DB64D: bcEval (svn/R-devel/src/main/eval.c:7022)
==4663==by 0x4E8197: Rf_eval (svn/R-devel/src/main/eval.c:688)
==4663==by 0x4E9D56: R_execClosure (svn/R-devel/src/main/eval.c:1853)
==4663==by 0x4EAB33: Rf_applyClosure (svn/R-devel/src/main/eval.c:1779)
==4663==by 0x4E8363: Rf_eval (svn/R-devel/src/main/eval.c:811)
==4663==by 0x4ECD01: do_set (svn/R-devel/src/main/eval.c:2920)
==4663==  Address 0x1616c100 is 7,600 bytes inside a block of size 7,960
alloc'd
==4663==at 0x483880B: malloc
(/builddir/build/BUILD/valgrind-3.15.0/coregrind/m_replacemalloc/vg_replace_malloc.c:309)
==4663==by 0x5223E0: GetNewPage (svn/R-devel/src/main/memory.c:946)

Please fix and resubmit.

Best wishes,
Yang

[[alternative HTML version deleted]]

__
R-package-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-package-devel



__
R-package-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-package-devel


Re: [R-pkg-devel] Proper way to ask a user to set permanent variables?

2020-01-14 Thread Rainer M Krug
I second that - it provides the most consistent way of storing information 
permanently.

I was in a similar situation, and ended up using the function at 

https://github.com/Exp-Micro-Ecol-Hub/dmdScheme/blob/master/R/cache.R 


And the location `rappdirs::user_config_dir(appname = "dmdScheme", appauthor = 
"dmdScheme”)` as the permanent cache.

I either either 
- use a temporary cache if the cache does not exist
- if the cache does exist, use that one, and
- use the `createPermanent` argument to create the cache so that it can be used.

Cheers,

Rainer


> On 14 Jan 2020, at 17:34, Gábor Csárdi  wrote:
> 
> You can use the rappdirs package to look up the standard places for
> permanent config, cache etc. files. E.g. on macOS:
> 
> ❯ rappdirs::user_cache_dir()
> [1] "/Users/gaborcsardi/Library/Caches"
> 
> Gabor
> 
> On Tue, Jan 14, 2020 at 4:10 PM Jonathan Greenberg  wrote:
>> 
>> Folks:
>> 
>> My package gdalUtils is a wrapper for a set of binaries on disk (the GDAL 
>> Utilities) -- these have about as many places to install as there are people 
>> installing it, and the system environment variables aren't always much help 
>> (they aren't always set) for locating them.  My package is trying to 
>> dummy-proof the usage as much as possible, so one of the things it does is 
>> if it can't find the install, it goes search for the install in, first, 
>> standard locations and runs a short test to see if the install is valid and, 
>> if not, goes on a longer hunt.  Right now, it does this search everytime 
>> someone boots up R and uses it, which slows down the process.
>> 
>> What I'm wondering is twofold:
>> 
>> 1) Are there any packages/methods by which user "preferences" are saved that 
>> don't require saving workspaces (e.g. does R have a standardized 
>> "preferences" location that packages can use).
>> 
>> 2) If the answer to #1 is "no", what is the preferred method for saving 
>> variables for use by packages that are always restored on boot -- e.g. I was 
>> thinking something like .Renviron but I think that's Rstudio only.  I'm 
>> concerned with workspace-type saves since I feel like that often results in 
>> a ton of variables being saved.
>> 
>> Thanks!
>> 
>> --j
>> 
>>[[alternative HTML version deleted]]
>> 
>> __
>> R-package-devel@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-package-devel
> 
> __
> R-package-devel@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-package-devel

--
Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, 
UCT), Dipl. Phys. (Germany)

Orcid ID: -0002-7490-0066

Department of Evolutionary Biology and Environmental Studies
University of Zürich
Office Y34-J-74
Winterthurerstrasse 190
8075 Zürich
Switzerland

Office: +41 (0)44 635 47 64
Cell:   +41 (0)78 630 66 57
email:  rainer.k...@uzh.ch
rai...@krugs.de
Skype: RMkrug

PGP: 0x0F52F982




[[alternative HTML version deleted]]

__
R-package-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-package-devel