What is the correct way to make a reprex that uses data read in from a local file?
Running reprex::reprex() on a local file I get
TCGA_BRCA_mRNAex_annotation <- readr::read_csv("main/data/Data_TCGA_BrCa_RNASeq_Expression_Trends/TCGA_BRCA_mRNAex_annotation.csv")
#> Error: 'main/data/Data_TCGA_BrCa_RNASeq_Expression_Trends/TCGA_BRCA_mRNAex_annotation.csv' does not exist in current working directory ('/private/var/folders/xs/bp9xghmn1sdfp3h6yz2j389nq5fs7n/T/RtmptpOSoW').
but then now there are output files with extensions .R, .html, .md, .utf8.md, generated with names derived from tempfile(). How do I get the reprex without having these files generated?
Reading data in from a local file is contrary to the goals of a reproducible example, which are for the example to be self-contained and not dependent on having access to your local file system.
Even though you got reprex to run in your second example, the result isn't reproducible: I can't copy and paste it and have it run, because I still don't have access to your CSV file.
This discussion has several ideas for how to include your own data in a reproducible fashion:
If you'd like feedback or help on how to make any of those solutions work for your case, definitely go ahead and ask!
P.S. Thank you for asking this question — it's a common point of confusion! And thank you even more for trying to make a reprex
Thanks @jcblum for the quick response! My objective was to share an example with only a colleague, who does have access to the local file system. I suppose using reprex would be overkill then in this case? The package was intended to produce examples for wider audiences.
I can see the benefit of using it in that context — one of my favorite things about reprex is how it seamlessly includes output as well as code, and you can’t beat the convenience.
As you’ve maybe already realized, reprex works by using knitr/Rmarkdown under the hood, which is why those intermediate files appear. Can you try setting outfile to a base name of your choice, instead of NA, so the files will at least be more easily removed with code?