Skip to content

Commit 021eb46

Browse files
committed
update
1 parent c8f04fb commit 021eb46

File tree

3 files changed

+21
-2
lines changed

3 files changed

+21
-2
lines changed

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: yulab.utils
22
Title: Supporting Functions for Packages Maintained by 'YuLab-SMU'
3-
Version: 0.1.8.001
3+
Version: 0.1.9
44
Authors@R: c(person("Guangchuang", "Yu", email = "guangchuangyu@gmail.com", role = c("aut", "cre"), comment = c(ORCID = "0000-0002-6485-8781")))
55
Description: Miscellaneous functions commonly used by 'YuLab-SMU'.
66
Imports:

NEWS.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# yulab.utils 0.1.8.001
1+
# yulab.utils 0.1.9
22

33
+ `c2()` to concate two vectors into a 'chunked_array' object (2024-12-03, Tue)
44

R/utilities.R

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,24 @@
11
`%||%` <- function(a, b) ifelse(is.null(a), b, a)
22

3+
.hi <- function(package = NULL, n=2L) {
4+
env <- sys.parent(n)
5+
6+
if (!is.null(env)) {
7+
caller <- deparse(sys.call(env))
8+
caller <- sub("(\\w+)\\(.*", "\\1", caller)
9+
if (is.null(package)) return(FALSE)
10+
if (get_caller_package(caller) %in% package) return(TRUE)
11+
}
312

13+
return(FALSE)
14+
}
415

16+
get_caller_package <- function(caller) {
17+
if (is.character) {
18+
fn <- eval(parse(text=caller))
19+
} else {
20+
fn <- caller
21+
}
522

23+
return(environmentName(environment(fn)))
24+
}

0 commit comments

Comments
 (0)