Skip to content

Printing a title for an object in the console when writing a function XXXX

2 messages · Dan Abner, David Winsemius

#
On May 7, 2011, at 4:16 AM, Dan Abner wrote:

            
?cat

fn3<-function(x,y){
cat("Please examine this beautiful title\n")
c1<-cov(x,y)
cat(" ... here is your covariance ... \n", c1)}
# Here is what I saw on my system
#> attach(data1)
#The following object(s) are masked _by_ '.GlobalEnv':
#
#   weight
# there was already a weight object in the workspace and the
# interpreter did not know which one to use
# and it was telling me it had 'decided' to use the other one
# So .... instead use with() as below:

 > with(data1, fn3(age,weight) )
# output ...
Please examine this beautiful title
  ... here is your covariance ...
  0.03096163
(And Dan, if you are a member of this list, then be advised that  
putting 'XXXX' in your subject line is going to get you email held by  
the spambot that 'thinks' you are advertising something more  
interesting than statistics.)

David Winsemius, MD
West Hartford, CT