purushothaman
2012-Jul-12 09:00 UTC
[R] How to Read source code of function as string vector or matrix
Hi, I need to read source code of function as a string vector or matrix. if i am using get method it return as closure type. example readcsv<-function(filepath) { output<-read.csv(filepath) } how to get as string vector like this test[1]=readcsv<-function(filepath) test[2]={ test[3]=output<-read.csv(filepath) test[4]=} Thanks B.Purushothaman -- View this message in context: http://r.789695.n4.nabble.com/How-to-Read-source-code-of-function-as-string-vector-or-matrix-tp4636270.html Sent from the R help mailing list archive at Nabble.com.
Thomas Petzoldt
2012-Jul-12 09:12 UTC
[R] How to Read source code of function as string vector or matrix
On 7/12/2012 11:00 AM, purushothaman wrote:> Hi, > > I need to read source code of function as a string vector or matrix. > > if i am using get method it return as closure type. > > example > > readcsv<-function(filepath) > { > output<-read.csv(filepath) > } > > how to get as string vector like this > test[1]=readcsv<-function(filepath) > test[2]={ > test[3]=output<-read.csv(filepath) > test[4]=} > > Thanks > B.Purushothaman?readLines Thomas
purushothaman
2012-Jul-12 09:16 UTC
[R] How to Read source code of function as string vector or matrix
Hi, readLines read a file and retrun as vector. i need to read particular function in Rfile. Thanks B.Purushothaman -- View this message in context: http://r.789695.n4.nabble.com/How-to-Read-source-code-of-function-as-string-vector-or-matrix-tp4636270p4636273.html Sent from the R help mailing list archive at Nabble.com.
Michael Weylandt
2012-Jul-12 15:06 UTC
[R] How to Read source code of function as string vector or matrix
?deparse And please include context -- relatively few of us use Nabble. Michael On Jul 12, 2012, at 4:16 AM, purushothaman <purushothaman.b at ge.com> wrote:> Hi, > > readLines read a file and retrun as vector. > > i need to read particular function in Rfile. > > Thanks > B.Purushothaman > > -- > View this message in context: http://r.789695.n4.nabble.com/How-to-Read-source-code-of-function-as-string-vector-or-matrix-tp4636270p4636273.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > 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.
jim holtman
2012-Jul-12 18:08 UTC
[R] How to Read source code of function as string vector or matrix
try this:> readcsv<-function(filepath)+ { + output<-read.csv(filepath) + }> readcsvfunction(filepath) { output<-read.csv(filepath) }> x <- capture.output(readcsv) > x[1] "function(filepath)" "{" "output<-read.csv(filepath)" [4] "}">On Thu, Jul 12, 2012 at 5:00 AM, purushothaman <purushothaman.b at ge.com> wrote:> Hi, > > I need to read source code of function as a string vector or matrix. > > if i am using get method it return as closure type. > > example > > readcsv<-function(filepath) > { > output<-read.csv(filepath) > } > > how to get as string vector like this > test[1]=readcsv<-function(filepath) > test[2]={ > test[3]=output<-read.csv(filepath) > test[4]=} > > Thanks > B.Purushothaman > > > -- > View this message in context: http://r.789695.n4.nabble.com/How-to-Read-source-code-of-function-as-string-vector-or-matrix-tp4636270.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > 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.-- Jim Holtman Data Munger Guru What is the problem that you are trying to solve? Tell me what you want to do, not how you want to do it.