This is quite strange behaviour - at least for R-novice as myself....

Consider this:

> testf <- function() { x <-2; sprintf("%s %f", "x =", x); return(x) }
> result <- testf()
> testf <- function() { x <-2; sprintf("%s %f", "x =", x) }
> result <- testf()
> testf()
[1] "x = 2.000000"

Apparently  adding return() statement and invoking function like this 
"result <- testf()"
suppresses output from sprintf()

Output from print() is NOT suppressed:

> testf <- function() { x <-2; print(c("x =", x)) }
> result <- testf()
[1] "x =" "2"
> testf <- function() { x <-2; print(c("x =", x)); return(x) }
> result <- testf()
[1] "x =" "2"

Is there a way to use sprintf() inside a function ?

I guess I can say: print(sprintf()) - is it the only solution for this ?

R

	[[alternative HTML version deleted]]


