Displaying 2 results from an estimated 2 matches for "placeholderfunction".
2011 Jan 14
1
Help on a Display function
>
I wanted to simulate the Matlab DISPLAY function for some time now.
After seeing a recent proposal by Gabor Grothendieck I came up with the
following solution,
display <- function(...) {
my_names <- lapply(substitute(placeholderFunction(...))[-1], deparse)
for (my in my_names) cat(my, "=", eval(parse(text=my)), "\n", sep=" ")
}
that works about as good as I would have hoped:
> a <- 1; b <- a + 1
> display(a, b, sin(1))
a = 1
b = 2
sin(1) = 0.841471
My questions:...
2011 Jan 14
2
question about deparse(substitute(...))
Dear R helpers:
I like to apply deparse(substitute()) on multiple arguments to collect the
names of the arguments into a character vector.
I used function test.fun as below. it works when there is only one input
argument. but it does not work for multiple arguements. can someone kindly
help?
test.fun <- function(...){deparse(substitute(...))}
test.fun(x) #this works
test.fun(x,y,z) # I like