为什么“return”函数不能在 R 中的函数内部进行管道传输?

Jul*_*ien 7 r function dplyr

library(dplyr)

func <- function() {
  return(1)
  return(2)
}

func_pipe <- function() {
  1 %>% return()
  return(2)
}

func()
# [1] 1

func_pipe()
# [1] 2
Run Code Online (Sandbox Code Playgroud)

为什么该func_pipe函数不在第一个处停止return