Re: [R] using cat to log to file with sapply

2018-02-14 Thread Bert Gunter
Not sure what you wanted to do.Note that you have "test'txt" and "log.txt" in your code. Using only "test.txt", the following worked fine for me: letters[1:5]->x logf<-"test.txt" cat('%%\n',file=logf) catf<-function(x,...,logfile='test.txt', append=TRUE){ cat(x,'\n',

Re: [R] using cat to log to file with sapply

2018-02-14 Thread Jeff Newmiller
Your call to catf in testit is after the return, so it is never called. FWIW my antibugging strategy (and readability strategy) is to never use the return function... I structure my logic to end up at the end with my desired function result in a variable and I simply put that variable on the

Re: [R] using cat to log to file with sapply

2018-02-14 Thread William Dunlap via R-help
testit<-function(x,...){ paste0('this is x: ',x)->y return(y) catf("++test=",...) } You return from the function before calling catf(). Remove the 'return(y)' and make 'y' the last expression in the function. Bill Dunlap TIBCO Software wdunlap tibco.com On

[R] using cat to log to file with sapply

2018-02-14 Thread Alexander.Herr
Hi List, I am trying to write unsuccessfully to a logfile with cat. Here my example code: letters[1:5]->x logf<-"test.txt" cat('%%\n',file=logf) catf<-function(x,...,logfile='log.txt', append=TRUE){ cat(x,'\n', file=logfile, append=append)} testit<-function(x,...){