<- list(base = "mean",
approved_pkgs dplyr = "All")
approved_pkgs#> $base
#> [1] "mean"
#>
#> $dplyr
#> [1] "All"
approved.rds
build_approved()
to build
your tibble.build_approved(approved_pkgs)
#> # A tibble: 289 × 2
#> function_name library
#> <chr> <chr>
#> 1 mean package:base
#> 2 rows_upsert package:dplyr
#> 3 src_local package:dplyr
#> 4 db_analyze package:dplyr
#> 5 n_groups package:dplyr
#> 6 distinct package:dplyr
#> 7 summarise_ package:dplyr
#> 8 group_split package:dplyr
#> 9 group_by_if package:dplyr
#> 10 sample_n package:dplyr
#> # … with 279 more rows
approved.rds
file
argument in
build_approved()
to save approved.rds instead of return the
tibble.<- tempdir()
dir
build_approved(approved_pkgs, file = file.path(dir, "approved.rds"))
logrx.approved
optionlogrx.approved
option to point to your
approved.rds
location. We recommend setting this in your
.Rprofile
.options(logrx.approved = file.path(dir, "approved.rds"))
logrx
will take it from there. When each program is
executed, packages and functions will be compared to
approved.rds
and if any unapproved use is found, it will be
logged within the “Unapproved Package and Functions” section.Let’s write a simple script summarizing mean mpg from mtcars. We save
this as mpg.R
in the temporary directory dir
and axecute()
it.
library(dplyr)
#>
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#>
#> filter, lag
#> The following objects are masked from 'package:base':
#>
#> intersect, setdiff, setequal, union
<- mtcars %>%
results group_by(cyl) %>%
summarize(mean = mean(mpg)) %>%
mutate(label = "Mean MPG")
%>%
results ::pivot_wider(names_from = cyl, values_from = mean, id_cols = label)
tidyr#> # A tibble: 1 × 4
#> label `4` `6` `8`
#> <chr> <dbl> <dbl> <dbl>
#> 1 Mean MPG 26.7 19.7 15.1
axecute(file.path(dir,"mpg.R"), remove_log_object = FALSE)
Here we have the log elements for “Used Package and Functions” and
“Unapproved Package and Functions”. We can see we used
library()
from package:base
and
pivot_wider
from package:tidyr
. We did not
include the base library or tidyr functions in our approved list, so
this has been logged!
#> --------------------------------------------------------------------------------
#> - Used Package and Functions -
#> --------------------------------------------------------------------------------
#> {package:base} library, mean
#> {package:dplyr} %>%, group_by, summarize, mutate
#> {package:tidyr} pivot_wider
#> --------------------------------------------------------------------------------
#> - Unapproved Package and Functions -
#> --------------------------------------------------------------------------------
#> {package:base} library
#> {package:tidyr} pivot_wider