0

Why doesn't reprex() find the variable?

a <- "a"
reprex(a)

a
#> Error in eval(expr, envir, enclos): Objekt 'a' nicht gefunden
Cevior
  • 97
  • 8
  • `a` should be an expression defining variable `a` because `a` itself doesn't exist in the new environment created by `reprex` : `reprex::reprex({a<-"a";a})` – Waldi Aug 18 '22 at 07:00
  • But how can I mask my data from the global environment to the reprex environment? – Cevior Aug 18 '22 at 07:13
  • No data from the global environment comes into reprex environment. In the example above, `a` is created anew in the reprex env. – Waldi Aug 18 '22 at 07:14
  • There's no chance of masking/copying? *Every* variable has to be created inside the reprex function?! Using just `reprex()` does not work either (on my side)... – Cevior Aug 18 '22 at 07:20
  • 2
    reprex is self contained : either you define the variable inside it explicitely, or the variable won't exist. This is the target of reprex : prove that the code will work everywhere, independenly of what you decided to mask / copy. See https://www.r-bloggers.com/2020/10/how-to-make-a-reprex/ – Waldi Aug 18 '22 at 07:58

0 Answers0