[Rd] parse(text=...) and the srcfile attribute

From: Deepayan Sarkar <deepayan.sarkar_at_gmail.com>
Date: Thu, 12 Jul 2007 18:52:50 -0700


Hi,

I'm trying to understand whether the new source file references can help me with something I want to do. Let's say I have

foo <- parse(text = "
a <- 1; b <- 2**2
a + b
")

I now wish to recover the sources for the parsed expressions. I can get them one at a time:

> foo[[2]]

b <- 2^2
> as.character(attr(foo, "srcref")[[2]])
[1] "b <- 2**2"

Is there a better way? Perhaps like the print method

> as.character(foo, useSource = TRUE)

could give all the sources at once?

-Deepayan



R-devel_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Fri 13 Jul 2007 - 01:53:52 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Fri 13 Jul 2007 - 02:36:17 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-devel. Please read the posting guide before posting to the list.