Skip to content

Commit e32da6c

Browse files
authored
fix deprecation message; add renaming to the examples (#362)
before: ``` r$> lifecycle::deprecate_soft("0.6.1", "datanames()", details = "names()") Warning message: `datanames()` was deprecated in <NA> 0.6.1. ℹ names() ``` after: ``` r$> lifecycle::deprecate_soft("0.6.1", "datanames()", with = "names()") Warning message: `datanames()` was deprecated in <NA> 0.6.1. ℹ Please use `names()` instead. ``` Also updated docs to give example of reassigning names - previously done with `datanames(x) <- ...` which is deprecated now
1 parent 7b8ec2e commit e32da6c

File tree

3 files changed

+31
-5
lines changed

3 files changed

+31
-5
lines changed

R/deprecated.R

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,20 @@
1919
#' @rdname datanames
2020
#' @export
2121
datanames <- function(x) {
22-
lifecycle::deprecate_soft("0.6.1", "datanames()", details = "names()")
22+
lifecycle::deprecate_soft(
23+
when = "0.6.1",
24+
what = "datanames()",
25+
with = "names()"
26+
)
2327
names(x)
2428
}
2529

2630
#' @rdname datanames
2731
#' @export
2832
`datanames<-` <- function(x, value) {
2933
lifecycle::deprecate_soft(
30-
"0.6.1",
31-
"`datanames<-`()",
34+
when = "0.6.1",
35+
what = "`datanames<-`()",
3236
details = "invalid to use `datanames()<-` or `names()<-` on an object of class `teal_data`. See ?names.teal_data"
3337
)
3438
x
@@ -39,8 +43,8 @@ datanames <- function(x) {
3943
#' @keywords internal
4044
`names<-.teal_data` <- function(x, value) {
4145
lifecycle::deprecate_warn(
42-
"0.6.1",
43-
"`names<-.teal_data`()",
46+
when = "0.6.1",
47+
what = "`names<-.teal_data`()",
4448
details = "invalid to use `datanames()<-` or `names()<-` on an object of class `teal_data`. See ?names.teal_data"
4549
)
4650
x

R/teal_data-names.R

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
#' To get the names of all objects, use `ls(x, all.names = TRUE)`, however, it
88
#' will not group the names by the join_keys topological structure.
99
#'
10+
#' In order to rename objects in the `teal_data` object, use base R functions (see examples).
11+
#'
1012
#' @param x A (`teal_data`) object to access or modify.
1113
#'
1214
#' @return A character vector of names.
@@ -16,9 +18,18 @@
1618
#' td <- within(td, mtcars <- mtcars)
1719
#' names(td)
1820
#'
21+
#' # hidden objects with dot-prefix
1922
#' td <- within(td, .CO2 <- CO2)
2023
#' names(td) # '.CO2' will not be returned
2124
#'
25+
#' # rename objects
26+
#' td <- teal_data(iris = iris)
27+
#' td <- within(td, {
28+
#' new_iris <- iris
29+
#' rm(iris)
30+
#' })
31+
#' names(td) # only 'new_iris' will be returned
32+
#'
2233
#' @export
2334
names.teal_data <- function(x) {
2435
# Sorting from `ls` can be safely done as environments don't have any order

man/names.teal_data.Rd

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)