-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathr_utils.R
44 lines (38 loc) · 1.34 KB
/
r_utils.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# utils.R
# 0.0.1
# 2024-01-25
# D.Kierans ([email protected])
#' unlock_envs
#' @description Unlock package- and name-spaces to change function definitions in packages.
#' Counterfunction for `lock_envs`
#' @param package_name String - name of package
unlock_envs <- function(package_name){
# namespace unlock
env <- asNamespace(package_name)
rlang::env_unlock(env = env)
rlang::env_binding_unlock(env = env)
# packagespace unlock
env <- as.environment(paste0("package:",package_name) )
rlang::env_unlock(env = env)
rlang::env_binding_unlock(env = env)
}
#' lock_envs
#' @description Lock package- and name-spaces to change function definitions in packages
#' Counterfunction for `unlock_envs`
#' @param package_name String - name of package
lock_envs <- function(package_name){
# namespace lock
env <- asNamespace(package_name)
rlang::env_binding_lock(env = env)
rlang::env_lock(env)
# spackspace lock
env <- as.environment(paste0("package:",package_name) )
rlang::env_binding_lock(env = env)
rlang::env_lock(env)
}
#' rTrace_time
#' @description Basic function timer, using R's Sys.time() for now
#' @return Current time
rTrace_time <- function() {
Sys.time()
}