Hi,

I'm writing a function that needs the input names (as characterstrings) as part 
of the output.
With deparse(substitute( ) ) that works fine, until I replace all zeros with 
0.001 (log is calculated at some time):

tf <- function(input) { input[input==0] <- 0.001 ;   deparse(substitute(input)) 
}
myguess <- 42
tf(myguess)     # not "myguess", but "42"


Now when I extract the input names before replacing the zeros, this works:

tf <- function(input) { out <- deparse(substitute(input)) ;   input[input==0] 
<- 0.001 ;   out }
tf(myguess)     # correct: "myguess"
myguess <- 0 ; tf(myguess) # ditto


While I did find a workaround, I'm still wondering why this happens.
Any hints on where to start reading?

Thanks ahead,
Berry

PS: R version 2.15.1 (2012-06-22) -- "Roasted Marshmallows"
Windows 7  - Platform: x86_64-pc-mingw32/x64 (64-bit)



                                          
        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to