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

Cannot use do.call with create.scatterplot #136

Open
stefaneng opened this issue Jul 12, 2023 · 1 comment
Open

Cannot use do.call with create.scatterplot #136

stefaneng opened this issue Jul 12, 2023 · 1 comment
Labels
bug Something isn't working

Comments

@stefaneng
Copy link
Contributor

library(BoutrosLab.plotting.general);

set.seed(13);

call.args <- list(
    formula = y ~ x,
    data = data.frame(
        x = rnorm(100),
        y = rnorm(100)
        ),
    main = 'Not going to work'
    );

do.call(create.scatterplot, call.args)
#> Error in function.name == "create.lollipopplot": comparison (1) is possible only for atomic and list types

Note that this does work with other BPG functions.

call.args <- list(
    x = rnorm(100)
    );

do.call(create.histogram, call.args);

Created on 2023-07-11 with reprex v2.0.2

Code errors here:
https://github.com/uclahs-cds/public-R-BoutrosLab-plotting-general/blob/main/R/create.scatterplot.R#L203-L208

@stefaneng stefaneng added the bug Something isn't working label Jul 12, 2023
@stefaneng
Copy link
Contributor Author

Note: I thought this was as simple as changing match.call() to sys.calls() but issues occur if evaluating (such as reprex).
The three cases to check if the function name can be accessed:

  1. Standard call: create.scatterplot(...)
  2. do.call(create.scatterplot, list(...))
  3. Evaluated in another context (such as reprex, etc.)

Current implementation using match.call() works for 1. and 3. but not 2. Using sys.calls() works for 1. and 2. but not 3.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant