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

Feature request: Scrub username from reprex #476

Open
szimmer opened this issue Jan 28, 2025 · 0 comments
Open

Feature request: Scrub username from reprex #476

szimmer opened this issue Jan 28, 2025 · 0 comments

Comments

@szimmer
Copy link

szimmer commented Jan 28, 2025

Many times when using packages like here or generating a file with tempfile, the file path includes the username. I'd like this to be scrubbed from a reprex. This can be accessed using Sys.getenv("username") and then replaced with ***, {username}, or something like that. I currently do this manually. Here's an example of where I've manually replaced my actual username with {username}:

library(foreign)

datafile <- tempfile()
codefile <- tempfile()
write.foreign(head(iris), datafile, codefile, package="SAS", dataname="iris_ds", validvarname="V7")
#> Some variable names were abbreviated or otherwise altered.
writeLines(readLines(datafile))
#> 5.1,3.5,1.4,0.2,1
#> 4.9,3,1.4,0.2,1
#> 4.7,3.2,1.3,0.2,1
#> 4.6,3.1,1.5,0.2,1
#> 5,3.6,1.4,0.2,1
#> 5.4,3.9,1.7,0.4,1
writeLines(readLines(codefile))
#> * Written by R;
#> *  write.foreign(head(iris), datafile, codefile, package = "SAS",  ;
#> 
#> PROC FORMAT;
#> value Species 
#>      1 = "setosa" 
#>      2 = "versicolor" 
#>      3 = "virginica" 
#> ;
#> 
#> DATA  iris_ds ;
#> INFILE  "C:\Users\{username}\AppData\Local\Temp\RtmpeAHqom\file5ff446a5df2" 
#>      DSD 
#>      LRECL= 21 ;
#> INPUT
#>  Sepal_Length
#>  Sepal_Width
#>  Petal_Length
#>  Petal_Width
#>  Species
#> ;
#> LABEL  Sepal_Length = "Sepal.Length" ;
#> LABEL  Sepal_Width = "Sepal.Width" ;
#> LABEL  Petal_Length = "Petal.Length" ;
#> LABEL  Petal_Width = "Petal.Width" ;
#> FORMAT Species Species. ;
#> RUN;
unlink(datafile)
unlink(codefile)

Created on 2025-01-28 with reprex v2.1.1

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