In an R script:
temp = function(aParam = 1) ls(envir=sys.frame(1))
temp()
The return value is:
[1] "aParam"
as expected.
In an Rmarkdown doc,
```{r}
temp = function(aParam = 1) ls(envir=sys.frame(1))
temp()
.```
the return value is a vector of 45 names starting with "base_pandoc_to".
Changing the frame number, I can't find the correct frame anywhere in the range -3 to 20.
Not a problem that can't be overcome, but I am curious to understand what's going on with sys.frame.
(Sorry for the stray dot, seems necessary to get this post to format roughly correctly.)