[R-pkg-devel] visible binding for '<<-' assignment

Ben Bolker bbo|ker @end|ng |rom gm@||@com
Fri Sep 4 00:05:25 CEST 2020


   OK, trying again.

   Would it work to save the unescaped versions in a .RData file as in 
https://cran.r-project.org/doc/manuals/r-release/R-exts.html#Data-in-packages 
?  Presumably the problems with non-ASCII variables arise when they show 
up in a text-format (e.g. .R) file, not when they are read from a 
binary-format file?

   Then, if you use LazyData: yes in the DESCRIPTION file (this may be 
the default?), these should automatically be accessible to users when 
the package is loaded?


On 9/3/20 4:31 PM, Dan Zigmond wrote:
> Hi, all. I am developing a package that includes some global variables.
> Because these are non-ASCII, I have escaped them. But then because these
> are difficult to read, I want to provide an easy way for users to unescape
> all of them up front. Thus I have code like to create and save the data in
> global variables in one file:
> 
> pali_vowels <-
>    c("a", "\u0101", "i", "\u012b", "u", "\u016b", "e", "o")
> pali_consonants <-
>    c("k", "kh", "g", "gh", "\u1e45",
>      "c", "ch", "j", "jh", "\u00f1",
>      "\u1e6d", "\u1e6dh", "\u1e0d", "\u1e0dh", "\u1e47",
>      "t", "th", "d", "dh", "n",
>      "p", "ph", "b", "bh", "m",
>      "y", "r", "l", "v", "s", "h", "\u1e37", "\u1e43")
> pali_alphabet <-c(pali_vowels, pali_consonants)
> use_data(pali_alphabet, overwrite = TRUE)
> 
> and then I try to export a function like this in another file:
> 
> pali_string_fix <- function() {
>    pali_alphabet <<-
>       stringi::stri_unescape_unicode(pali_alphabet)
>    # Several more of these...
>    }
> 
> The idea is that users can run pali_string_fix() once when they load the
> package and then they won't need to deal with all the Unicode escape
> sequences after that.
> 
> However, this is getting rejected by the CRAN checks with the message:
> 
> * checking R code for possible problems ... [4s] NOTE
> pali_string_fix: no visible binding for '<<-' assignment to
>    'pali_alphabet'
> 
> I'm guessing this is because the data and the function are defined in
> different files, so even though those globals are defined by my package,
> that isn't obvious when the check is run on this code.
> 
> Does anyone have advice for how to fix this?
> 
>       Dan
> 
> .
> -------------------------
> Dan Zigmond
> djz using shmonk.com
> 
> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> R-package-devel using r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-package-devel
>



More information about the R-package-devel mailing list