Tools for Fix Functions in R Packages
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
R
man
tests
.Rbuildignore
.gitignore
DESCRIPTION
NAMESPACE
README.Rmd
README.md
fixer.Rproj
stanfit.rds

README.md

fixer - Tools for Fix Functions in R Packages

df <- read.table(text = "foo bar")
df
##    V1  V2
## 1 foo bar
df$V1 # factor
## [1] foo
## Levels: foo
library(fixer)
fix_params(read.table(stringsAsFactors = FALSE))

df <- read.table(text = "foo bar")
df$V1 # vector
## [1] "foo"
fix_info()
##   package_name  func_name persist
## 1        utils read.table   FALSE
fix_params(rnorm(mean=100))
rnorm(1)
## [1] 99.56816
rnorm(1, mean=0)
## [1] -0.4471872
fix_info()
##   package_name  func_name persist
## 1        utils read.table   FALSE
## 2        stats      rnorm   FALSE
fix_reset(rnorm)
fix_info()
##   package_name  func_name persist
## 1        utils read.table   FALSE
fix_params_persist(rnorm(mean=100))
rnorm(1)
## [1] 99.52143
rnorm(1, mean=0)
## [1] 100.4171
fix_info()
##   package_name  func_name persist
## 1        utils read.table   FALSE
## 2        stats      rnorm    TRUE
fix_reset_all()
fix_info()
## [1] package_name func_name    persist     
## <0 rows> (or 0-length row.names)

Program Slicing

utils:::head.default
## function (x, n = 6L, ...) 
## {
##     stopifnot(length(n) == 1L)
##     n <- if (n < 0L) 
##         max(length(x) + n, 0L)
##     else min(n, length(x))
##     x[seq_len(n)]
## }
## <bytecode: 0x00000000067864c8>
## <environment: namespace:utils>
library(fixer)
fix_slicing(utils:::head.default(n = 3))
## function (x, `n = 3`, ...) 
## {
##     stopifnot(TRUE)
##     n <- min(3, length(x))
##     x[seq_len(n)]
## }
## <environment: namespace:utils>