Stephen Tucker
2010-Feb-10 17:37 UTC
[R] Compose in roxygen - order of function application?
Hello, I wonder if anyone has used the Compose() function in the 'roxygen' package. I find its behavior a bit surprising:> f <- function(x) x + 1 > g <- function(x) x * 2 > f(g(2))[1] 5> Compose(f,g)(2)[1] 6> g(f(2))[1] 6> Compose(g,f)(2)[1] 5 I would have expected Compose(f,g)(x) == f(g(x)) but it appears the order of application is reversed. It would be easy for me to modify with rev(): Compose <- function (...) { fs <- rev(list(...)) function(...) Reduce(function(x, f) f(x), fs, ...) } But does the current implementation follow another convention I am unaware of? Thanks - Stephen
Apparently Analagous Threads
- [Roxygen-devel] Roxygen: @example tag does not work for me
- New package Rd2roxygen: Convert Rd to roxygen documentation
- Conditional importFrom (roxygen?)
- Roxygen: question regarding 'use.Rd2' and creation of DESCRIPTION
- Problem accessing functions in package 'roxygen'