Dear UseRs,

please find below a simple example which exemplifies my question. 
In words, I'd like to write a function which prints formula and outcomes only 
when results are not assigned or recalling the already assigned object, as e.g. 
glm.
I'm sure a solution is rather simple and straightforward and it has something 
to do with match.call (maybe), but I'm not able to see it.

Thanks in advance for any help
Carlo G. Camarda

# my simple function
myFUN <- function(a, b, method){
    res <- ifelse(method==1, a+b, a-b)
    object <- list(res=res, call=match.call())
    return(object)
}
# assigning to A
A <- myFUN(2,4,1)
# recalling A or don't assign ...
A
myFUN(2,4,1)

# ... what I'd like (somehow) to have when
# I don't assign myFUN to another obj
# or when I recall the obj itself
My simple analysis

Call: myFUN(a = 2, b = 4, method = 1)

a: 2
b: 4
Outcome: 6


-----------------------------------------------------
Carlo Giovanni Camarda
Research Scientist
Konrad-Zuse-Straße 1
18057 Rostock - Germany
Phone: +49 381 2081 172
Fax: +49 381 2081 472
[EMAIL PROTECTED]
http://www.demogr.mpg.de/en/staff/camarda/default.htm
-----------------------------------------------------


----------
This mail has been sent through the MPI for Demographic ...{{dropped:10}}

______________________________________________
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