[R] sink() within a function?

Jon Stearley jrstear at sandia.gov
Wed Jun 1 17:49:14 CEST 2005


sink() isn't behaving as i expect, when used inside a function, eg:
   x<-data.frame(F=c("O","O"))
   f<-"foo.txt"
   sink(f); format(x); sink();   # foo.txt looks great!
   foo<-function(x,f) { sink(f); format(x); sink(); }
   foo(x,f=f) # foo.txt is empty!
why is this, and how can i successfully sink() within a function?

my real function does some rearrangement and formatting, but the above 
illustrates the problem i'm encountering.  thx in advance for any help! 
    [MacOS 10.3, R 2.0.1]

-- 
+--------------------------------------------------------------+
| Jon Stearley                  (505) 845-7571  (FAX 844-9297) |
| Sandia National Laboratories  Scalable Systems Integration   |
+--------------------------------------------------------------+

one more clue:
   library(debug); mtrace(foo); foo(x,f=f); ...  # foo.txt is not empty!




More information about the R-help mailing list