Skip to content
Prev 316649 / 398506 Next

How does this function print, why is n1 which equals 1 printed as 2?

On 13-02-01 8:47 AM, John Sorkin wrote:
I haven't run the code, but presumably it's just the usual auto 
printing.  Unless a function sets the result to be invisible, results
of functions are printed by calling print() after they are returned.

Since your function returns something with class

c("n.for.2means", "list")

R will look for a print method for those classes, and use it to print 
the result.  There's no print.list method in standard R; it just uses 
the default.  But there's probably a print.n.for.2means function in the 
package (possibly not exported; you might need 
epicalc:::print.n.for.2means to see it).  There might be a print.list 
function there instead or as well.

Duncan Murdoch