[R-pkg-devel] Best way to cache a dataframe available for all functions in a package

2021-11-26 Thread X FiM
Dear all,

I am writing a package that needs to load some data from a URL and have
such data (meta data) available when using other functions in the package,
and I would like some advice on how to properly manage such situation.


My first guess would be to create a function to downloads that meta data,
and make this function run when loading the package. I am even familiar
with this, and I could manage.

But the second part, making this sort of data frame available for other
functions in the package, how can I achieve it? Of course I can call the
function that downloads and prepares the data at every use of the other
functions, but that would mean connecting to the Internet again and again.
So, in other words, is there a way to "cache" into memory a data frame
(without having to create an object)?

How could I achieve such thing? What are the kind of keywords that I need
to use when looking for help?

Thank you very much,

-- 
Xavier

[[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] Best way to cache a dataframe available for all functions in a package

2021-11-26 Thread X FiM
Dear Lionel, Hugh and Dirk,

Many, many thanks for your input. I will definitively study the different
proposals and will check on the different implementations and ideas to
evaluate what is the most convenient. And will do a crash course on
environments and learn something new.

At first sight the bit at the "spData" package seems quite appropriate for
me. I may take the liberty to ask again if I got stuck.

Best regards and, again, thank you.

Missatge de Dirk Eddelbuettel  del dia dv., 26 de nov. 2021
a les 16:10:

>
> Agreed. I have used `.pkgenv` in a few packages (digest, rpushbullet, ...),
> and usually added a comment that it is package-global.
>
> And so have a few others:
>
>  https://github.com/search?l=R&q=org%3Acran+pkgenv&type=Code
>
> Dirk
>
> --
> https://dirk.eddelbuettel.com | @eddelbuettel | e...@debian.org
>
> __
> R-package-devel@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-package-devel
>

[[alternative HTML version deleted]]

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


[R-pkg-devel] UTF-8 characters inside R functions for data transformation

2021-12-21 Thread X FiM
Dear all,

Somewhat related to a question that I posted a while ago (see
https://stat.ethz.ch/pipermail/r-package-devel/2021q4/007540.html), once
I've got a dataframe in my cache, some of the functions need to use some of
the variables. It turns out that some of the columns contain UTF-8
characters, and therefore I need to be able to call
`metadata$variable.with.áccénts`.

But the package development checks warn me that no non-ASCII characters are
allowed in the files "checking R files for non-ASCII characters ...
WARNING".

I have specified that the package uses UTF-8 in DESCRIPTION ("Encoding:
UTF-8"). I have also defined "options(encoding = "UTF-8")" before calling
the checks, but nothing seems to matter. I have also tried to give the
proper UTF-8 codes, like in `metadata$variable.with.\u00e1cc\u00e9nts`, but
with no luck either. Also it gives an error with "\u sequences not
supported inside backticks".

So which approach do you recommend? Is there any solution that I can use to
call variables that use non-ASCII characters?

Thank you very much.

-- 
Xavier

[[alternative HTML version deleted]]

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