#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()
Run the code above in your browser using DataLab