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?