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

Section 7.4.4 Execution environments: clarify by using, say, h(5) instead of h(1) #1745

Open
HenrikBengtsson opened this issue Oct 21, 2022 · 0 comments

Comments

@HenrikBengtsson
Copy link
Contributor

HenrikBengtsson commented Oct 21, 2022

In Section 7.4.4 Execution environments, there's:

adv-r/Environments.Rmd

Lines 656 to 663 in dc49c38

```{r}
h <- function(x) {
# 1.
a <- 2 # 2.
x + a
}
y <- h(1) # 3.
```

image

Here there are several uses of 1, 2, and 3 in different roles, e.g. the value of x, the value of a, and y, while also being used as labels for steps 1, 2, and 3 both in the code and in the graphs. This can complicate the parsing of the code and the graphs.

My suggestion is to initiate x with another value, to avoid clashing with the step labels, e.g.

h <- function(x) {
  # 1.
  a <- 4 # 2.
  x + a
}
y <- h(5) # 3.

would change the graph enough so that the binding values are x = 5, a = 4, and y = 9.

@HenrikBengtsson HenrikBengtsson changed the title Section 7.4.4 Execution environments: clarify by using, say, h(36) instead of h(1) Section 7.4.4 Execution environments: clarify by using, say, h(5) instead of h(1) Oct 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant