Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

batchExport() and objects with non-standard names #93

Open
HenrikBengtsson opened this issue Jun 7, 2015 · 2 comments
Open

batchExport() and objects with non-standard names #93

HenrikBengtsson opened this issue Jun 7, 2015 · 2 comments

Comments

@HenrikBengtsson
Copy link
Contributor

Problem

It is not possible to export objects with non-standard names, e.g.

> batchExport(reg, li=list("%>%"=NA))
Error in batchExport(reg, li = list(`%>%` = NA)) :
  Assertion on 'li' failed: Vector must be named according to R's variable naming rules

Troubleshooting

This due to the following assertion:

assertList(li, names = "strict")

Suggestion

I propose to make names="strict" and argument of batchExport(), e.g.

batchExport <- function (reg, ..., li = list(), overwrite = FALSE, names = "strict")
{
    checkRegistry(reg)
    ddd = list(...)
    assertList(li, names = names)
    assertList(ddd, names = names)
...

so that it's possible to do:

> batchExport(reg, li=list("%>%"=NA), names = "any")

The argument name names might not be the most informative though to a user of batchExport().

@HenrikBengtsson HenrikBengtsson changed the title batchExport() and objects that with non-standard names batchExport() and objects with non-standard names Jun 7, 2015
@HenrikBengtsson
Copy link
Contributor Author

Just discovered another use case:

globals <- list("names<-"=NA)
batchExport(reg, li=globals)
Error in batchExport(reg, li = list(`%>%` = NA)) :
  Assertion on 'li' failed: Vector must be named according to R's variable naming rules

assertList(li, names = "strict")

@HenrikBengtsson
Copy link
Contributor Author

So, assertList() is not the main issue, but rather the restriction on put() on fail objects that is called by batchExport():

    f = fail(...)
...
    f$put(li = li)
    f$put(li = ddd)

The restriction on "keys" for fail objects is basically [a-zA-Z0-9._-]+, cf. help("fail", package="fail").

In other words, it looks like the fail package needs to be update to support other type of variable names.

An alternative is to have batchExport() / loadExport() / batchUnexport() to encode/decode variable names to filename compatible strings. Can key <- utils::URLencode(var, reserved = TRUE) and var <- utils::URLdecode(key) be used for this?

EDIT: URL decode/encode functions are in the utils package (not tools).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants