Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
gvegayon committed Jan 26, 2023
1 parent 818d9d2 commit f83df19
Show file tree
Hide file tree
Showing 3 changed files with 431 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@
.Rhistory
.RData
.Ruserdata
*.pdf

405 changes: 405 additions & 0 deletions week-03/README.html

Large diffs are not rendered by default.

25 changes: 24 additions & 1 deletion week-03/README.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ title: "Lab 03 - Functions and data.table"
format:
html:
embed-resources: true
editor_options:
chunk_output_type: console
---

# Learning goals
Expand Down Expand Up @@ -90,7 +92,28 @@ Once you are done setting up the project, you can now start working on the lab.
Write a function using the ellipsis argument (`...`) with the goal of (i) retrieving the list of arguments passed to it, (ii) printing information about them using `str()`, and (iii) printing the environment where they belong and the address of the object in memory using `data.table::address()`.

```{r}
# plot_x <- function(x, y, ...) {
# plot(x = x, y = y, main = "Experiment", col = "red", ...)
# }
my_e <- function(...) {
val <- list(...)
lapply(val, str)
for (a in val)
environment(a)
lapply(val, \(x) {
print(data.table::address(x))
})
lapply(val, \(x) {
data.table::address(x)
})
invisible()
}
my_e(123, pi)
my_e(123, pi = pi)
```

Knit the document, commit your changes, and push them to GitHub.
Expand Down

0 comments on commit f83df19

Please sign in to comment.