get_piped_name: get piped name

View source: R/get_piped_name.R

get_piped_nameR Documentation

get piped name

Description

this function captures the name of an object piped into a function, and returns as a string. Powers the automatic naming found in presenter.

Usage

get_piped_name(object, default_name = "Table")

Arguments

object

an object

default_name

string Attempts to return this string if an error occurs.

Value

string

Examples


#necessary to specify this option when using get_piped_name in knitr
options(rlang_trace_top_env = rlang::current_env())


### works if the object is piped or given as an argument
iris %>%
get_piped_name()

get_piped_name(iris)

### can even extract name from multistep pipes
iris %>%
dplyr::select(1:3) %>%
get_piped_name()

### can be placed inside other functions to capture the name and save it

find_name <- function(x){
 get_piped_name() -> new_name

 new_name
}

iris %>%
dplyr:select(1:3) %>%
find_name()


presenter documentation built on Feb. 16, 2023, 5:13 p.m.