[R] using cat to log to file with sapply
Alexander.Herr at csiro.au
Alexander.Herr at csiro.au
Thu Feb 15 01:16:19 CET 2018
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,...){
paste0('this is x: ',x)->y
return(y)
catf("++++++++++++++++++test=============",...)
}
sapply(x, function(x) testit(x, logfile=logf))
Any suggestions appreciated.
Thanks
Herry
More information about the R-help
mailing list