Spencer Graves
2014-May-07 21:23 UTC
[R] as.character(quote(x$y) ) = "$" "x" "y" not "x$y"?
Hello, All: Is there a simple utility someplace to convert "quote(x$y)" to "x$y"? I ask, because as.character(quote(x$y)) is a character vector of length 3 = "$" "x" "y". I want to convert this to "x$y" for a diagnostic message. class(quote(x$y)) = "call", which suggests I could write "as.character.call" to perform this function. However, before I do, I felt a need to ask for other thoughts on this. Thanks, Spencer
Richard M. Heiberger
2014-May-07 21:26 UTC
[R] as.character(quote(x$y) ) = "$" "x" "y" not "x$y"?
> deparse(quote(x$y))[1] "x$y" On Wed, May 7, 2014 at 5:23 PM, Spencer Graves <spencer.graves at structuremonitoring.com> wrote:> Hello, All: > > > Is there a simple utility someplace to convert "quote(x$y)" to "x$y"? > > > I ask, because as.character(quote(x$y)) is a character vector of > length 3 = "$" "x" "y". I want to convert this to "x$y" for a diagnostic > message. > > > class(quote(x$y)) = "call", which suggests I could write > "as.character.call" to perform this function. However, before I do, I felt > a need to ask for other thoughts on this. > > > Thanks, > Spencer > > ______________________________________________ > 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.
> deparse(quote(x$y))[1] "x$y" It looks like deparse does what you want here. On Wed, May 7, 2014 at 3:23 PM, Spencer Graves <spencer.graves at structuremonitoring.com> wrote:> Hello, All: > > > Is there a simple utility someplace to convert "quote(x$y)" to "x$y"? > > > I ask, because as.character(quote(x$y)) is a character vector of > length 3 = "$" "x" "y". I want to convert this to "x$y" for a diagnostic > message. > > > class(quote(x$y)) = "call", which suggests I could write > "as.character.call" to perform this function. However, before I do, I felt > a need to ask for other thoughts on this. > > > Thanks, > Spencer > > ______________________________________________ > 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.-- Gregory (Greg) L. Snow Ph.D. 538280 at gmail.com