'Anonymous Recursive Pipes in R

I'm trying to do anonymous recursion in R and also playing with pipes to learn. The code below works well

sorttt <- function(list){
  if (length(list) == 0) c() else c(max(list), Recall(list[list < max(list)]))
}

example %>% sorttt

But this code errors out with the error: Error in example %>% function(list) { : invalid formal argument list for "function"

example %>% function(list){if (length(list) == 0) c() else c(max(list), Recall(list[list < max(list)]))}

Does anyone know why these two might act differently? These seem to be logically the same thing.

r


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source