Here's a little function that will format an object in the StackOverflow style:
formatSO <- function(x) { y <- get(x, parent.frame()) d <- deparse(y) cat(" ", x, "<-", d[1], "\n") cat(paste(" ", d[-1], "\n", sep=""), sep="") }
And try:
> foo<-function(x,y){ + z<-x*y + super.z<-z^2 + return(super.z) + } > formatSO("foo") foo <- function (x, y) { z <- x * y super.z <- z^2 return(super.z) } > x <- 5:3 > formatSO("x") x <- c(5L, 4L, 3L)
source share