[R] Printing values within a function

Gabor Grothendieck ggrothendieck at myway.com
Wed Feb 18 05:46:36 CET 2004

Here are two ways:

f <- function(x) print(2*x)
g <- function(x) cat("the value of twice x is", 2*x, "\n")

Date:   Tue, 17 Feb 2004 20:41:39 -0800 
From:   Jonathan Greenberg <greenberg at ucdavis.edu>
To:   R-help <r-help at stat.math.ethz.ch> 
Subject:   [R] Printing values within a function 

This is probably a really stupid question, but how do I print the value of a
variable within a function? Of course in normal command-line mode I just
type the name of the variable, but how do I have this value exported within
a function?

More information about the R-help mailing list