Message-ID: <E66794E69CFDE04D9A70842786030B933FA1C8E8@PA-MBX01.na.tibco.com>
Date: 2013-12-13T15:24:39Z
From: William Dunlap
Subject: how can i write the function into a file c:/mytest.R with cat function?
In-Reply-To: <tencent_3A82DB05585DDBD410796665@qq.com>
If you need to use cat() (why?) try using deparse() or format() on the function
cat("mytest <- ", deparse(mytest), sep="\n", file=file)
but dump() is easier
dump("mytest",file=file)
Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com
> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On Behalf
> Of ????
> Sent: Friday, December 13, 2013 3:16 AM
> To: r-help
> Subject: [R] how can i write the function into a file c:/mytest.R with cat function?
>
> mytest<-function(x,f){
> sum(x*f)/sum(f)
> }
> cat(mytest,file="c:/mytest.R")
> Error in cat(list(...), file, sep, fill, labels, append) :
> argument 1 (type 'closure') cannot be handled by 'cat'
>
> how can i write the mytest function into a file c:/mytest.R with cat function?
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.