Re: [R-pkg-devel] Assigning a variable to global environment

2020-12-11 Thread Avi Gross via R-package-devel
ot so much impact what other functions see in the environment. -Original Message- From: R-package-devel On Behalf Of Tiago Olivoto Sent: Friday, December 11, 2020 2:12 PM To: Ben Bolker Cc: R Package Devel Subject: Re: [R-pkg-devel] Assigning a variable to global environment Thanks

Re: [R-pkg-devel] Assigning a variable to global environment

2020-12-11 Thread Mark Miller
Correct me if I'm wrong, but this seems to be the purpose of the function `with`? https://www.rdocumentation.org/packages/base/versions/3.6.2/topics/with If that's the feature you're looking for, it would be the case of informing your users to use that function when they want to refer to the colu

Re: [R-pkg-devel] Assigning a variable to global environment

2020-12-11 Thread Mark Miller
I think it would be helpful to describe more deeply what you're trying to do by this. There's a fair chance there's a better way to do what you're trying to do. Mark On Fri, Dec 11, 2020 at 10:53 AM Tiago Olivoto wrote: > Thank Matt for your response. > Would be an acceptable solution to check

Re: [R-pkg-devel] Assigning a variable to global environment

2020-12-11 Thread Tiago Olivoto
Thanks, everyone, Following Mark suggestion: The problem I'm trying to solve is: Users of my package metan (https://CRAN.R-project.org/package=metan), sometimes need to extract 2-3 variables from a given data.frame and put them as vectors in the global environment to use in other package's functi

Re: [R-pkg-devel] Assigning a variable to global environment

2020-12-11 Thread Ben Bolker
I think this solution will *not* be acceptable to CRAN. (The policy doesn't say "don't modify the global workspace unless you're careful", it says "don't modify the global workspace".) You can ask for an exception, but your chances of success are very low. It would be best to find a way

Re: [R-pkg-devel] Assigning a variable to global environment

2020-12-11 Thread Tiago Olivoto
Thank Matt for your response. Would be an acceptable solution to check if the variable exists first and creating the new variable with a suffix? Please, see the following example var_name <- "name" var_name <- ifelse(exists(var_name), paste(var_name, "_vct", sep =

Re: [R-pkg-devel] Assigning a variable to global environment

2020-12-11 Thread Matt Denwood
> On 11 Dec 2020, at 18:32, Tiago Olivoto wrote: > > Hi everyone, > This can be a very simple question, but I really have the following doubt. > > CRAN Policies says that 'Packages should not modify the global environment > (user’s workspace)'. So, may I or may I not create a function that will

[R-pkg-devel] Assigning a variable to global environment

2020-12-11 Thread Tiago Olivoto
Hi everyone, This can be a very simple question, but I really have the following doubt. CRAN Policies says that 'Packages should not modify the global environment (user’s workspace)'. So, may I or may I not create a function that will call internally the following code? (a simple example) assign(