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

Document how index arg works for nested functions #214

Open
richierocks opened this issue Oct 23, 2018 · 1 comment
Open

Document how index arg works for nested functions #214

richierocks opened this issue Oct 23, 2018 · 1 comment
Labels

Comments

@richierocks
Copy link
Contributor

Consider this ggplot

library(ggplot2)
ggplot(Orange, aes(age, circumference)) +
  geom_point() +
  geom_line(aes(color = Tree))

This has 2 calls to aes(), so on first glance, it seems I want to check this with

ex() %>% check_function("ggplot") %>% {
  check_arg(., "data") %>% check_equal()
  check_arg(., "mapping") %>% check_function("aes") %>% {
    check_arg(., "x") %>% check_equal(eval = FALSE)
    check_arg(., "y") %>% check_equal(eval = FALSE)
  }
}
ex() %>% check_function("geom_point") %>% {
  check_arg(., "mapping") %>% check_function("aes", index = 2) %>% {
    check_arg(., "color") %>% check_equal(eval = FALSE)
  }
}

But the each call to aes() is nested inside another check_function(), and I think this is restricting the scope. So I think the SCTs I really need are

ex() %>% check_function("ggplot") %>% {
  check_arg(., "data") %>% check_equal()
  check_arg(., "mapping") %>% check_function("aes") %>% {
    check_arg(., "x") %>% check_equal(eval = FALSE)
    check_arg(., "y") %>% check_equal(eval = FALSE)
  }
}
ex() %>% check_function("geom_point") %>% {
  check_arg(., "mapping") %>% check_function("aes") %>% {  # <- this line different
    check_arg(., "color") %>% check_equal(eval = FALSE)
  }
}

It's worth having an example of how the index is calculated: on the whole code or on a subset of the code provided by the state.

@hermansje
Copy link
Member

The first SCT was the way it worked before we fixed #206.
The second SCT is how it was intended and how it should work, after deploying that fix.

I will add an example.

@hermansje hermansje added the docs label Oct 26, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants