I've built a package that contains only two functions for a test run. They are:
g <- function(x){
? ? ? ?x <- x^2
? ? ? ?class(x) <- "foo"
? ? ? ?x
}
print.foo <- function(x, ...){
? ? ? ?cat("This is a test:\n")
? ? ? ?cat(x, "\n")
? ? ? ?invisible(x)
? ? ? ?}
Simply testing these functions in the R workspace prior to a build yields:
This is a test:
1 4 9 16 25
Now, I includes a NAMESPACE for this package, and it includes only the following:
export(g)
Package build is now succesful. However, here is what occurs:
[1] ?1 ?4 ?9 16 25
attr(,"class")
[1] "foo"
Why is the attribute printed on screen here whereas this does not occur when the function print.foo is simply sourced into the R workspace?
Thanks,
Harold
R version 2.10.0 (2009-10-26)
i386-pc-mingw32
locale:
[1] LC_COLLATE=English_United States.1252
[2] LC_CTYPE=English_United States.1252
[3] LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C
[5] LC_TIME=English_United States.1252
attached base packages:
[1] stats ? ? graphics ?grDevices utils ? ? datasets ?methods ? base
other attached packages:
[1] foo_1.0