as.character(quote(x$y) ) = "$" "x" "y" not "x$y"?

classic Classic list List threaded Threaded
18 messages Options
Reply | Threaded
Open this post in threaded view
|

as.character(quote(x$y) ) = "$" "x" "y" not "x$y"?

Spencer Graves-2
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

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: as.character(quote(x$y) ) = "$" "x" "y" not "x$y"?

Richard M. Heiberger
> deparse(quote(x$y))
[1] "x$y"

On Wed, May 7, 2014 at 5:23 PM, Spencer Graves
<[hidden email]> 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
>
> ______________________________________________
> [hidden email] 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.

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: as.character(quote(x$y) ) = "$" "x" "y" not "x$y"?

glsnow
In reply to this post by Spencer Graves-2
> 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
<[hidden email]> 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
>
> ______________________________________________
> [hidden email] 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.
[hidden email]

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: as.character(quote(x$y) ) = "$" "x" "y" not "x$y"?

Bert Gunter
... and

> str(quote(x$y))
 language x$y

> as.list(quote(x$y))
[[1]]
`$`

[[2]]
x

[[3]]
y

## may be instructive.

Cheers,
Bert




Bert Gunter
Genentech Nonclinical Biostatistics
(650) 467-7374

"Data is not information. Information is not knowledge. And knowledge
is certainly not wisdom."
H. Gilbert Welch




On Wed, May 7, 2014 at 2:30 PM, Greg Snow <[hidden email]> wrote:

>> 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
> <[hidden email]> 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
>>
>> ______________________________________________
>> [hidden email] 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.
> [hidden email]
>
> ______________________________________________
> [hidden email] 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.

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: as.character(quote(x$y) ) = "$" "x" "y" not "x$y"?

Spencer Graves-2
       Thanks for the quick replies from Richard Heiberger, Greg Show &
Bert Gunter.


       Might it make sense to create as.character.call as an alias for
deparse?


       A few years ago, I wrote several functions like "predict.fd" as
aliases for functions with less memorable names like "eval.fd".  Doing
that made the "fda" package easier to use, at least for me ;-)


       Thanks again,
       Spencer


On 5/7/2014 2:39 PM, Bert Gunter wrote:

> ... and
>
>> str(quote(x$y))
>   language x$y
>
>> as.list(quote(x$y))
> [[1]]
> `$`
>
> [[2]]
> x
>
> [[3]]
> y
>
> ## may be instructive.
>
> Cheers,
> Bert
>
>
>
>
> Bert Gunter
> Genentech Nonclinical Biostatistics
> (650) 467-7374
>
> "Data is not information. Information is not knowledge. And knowledge
> is certainly not wisdom."
> H. Gilbert Welch
>
>
>
>
> On Wed, May 7, 2014 at 2:30 PM, Greg Snow <[hidden email]> wrote:
>>> 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
>> <[hidden email]> 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
>>>
>>>
>>>
>>> --
>>> Gregory (Greg) L. Snow Ph.D.
>>> [hidden email]
>>>
>>> ______________________________________________
>>> [hidden email] 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.

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: as.character(quote(x$y) ) = "$" "x" "y" not "x$y"?

Spencer Graves-2
In reply to this post by Bert Gunter
          "as.character.call" seems not to work as an alias for deparse.
Consider the following:


xDy <- quote(x$y)
class(xDy)
"call"
as.character.call <- function(x, ...)deparse(x, ...)
as.character(xDy)
[1] "$" "x" "y"
# fails

str(xDy)
#  language x$y
as.character.language <- function(x, ...)"language"

as.character(xDy)
[1] "$" "x" "y"


          Is it feasible to construct a method for "as.character" that works
for objects of class "call"?


          Thanks,
          Spencer


#################


Thanks for the quick replies from Richard Heiberger, Greg Show & Bert
Gunter.


       Might it make sense to create as.character.call as an alias for
deparse?


       A few years ago, I wrote several functions like "predict.fd" as
aliases for functions with less memorable names like "eval.fd".  Doing
that made the "fda" package easier to use, at least for me ;-)


       Thanks again,
       Spencer


On 5/7/2014 2:39 PM, Bert Gunter wrote:

> ... and
>
>> str(quote(x$y))
>   language x$y
>
>> as.list(quote(x$y))
> [[1]]
> `$`
>
> [[2]]
> x
>
> [[3]]
> y
>
> ## may be instructive.
>
> Cheers,
> Bert
>
>
>
>
> Bert Gunter
> Genentech Nonclinical Biostatistics
> (650) 467-7374
>
> "Data is not information. Information is not knowledge. And knowledge
> is certainly not wisdom."
> H. Gilbert Welch
>
>
>
>
> On Wed, May 7, 2014 at 2:30 PM, Greg Snow <[hidden email]> wrote:
>>> 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
>> <[hidden email]> 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
>>>
>>>
>>>
>>> --
>>> Gregory (Greg) L. Snow Ph.D.
>>> [hidden email]
>>>
>>> ______________________________________________
>>> [hidden email] 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.

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: as.character(quote(x$y) ) = "$" "x" "y" not "x$y"?

Bert Gunter
[1] "x$y"

Spencer:

Does

deparse(substitute(x$y))
[1] "x$y"

do what you want?

Cheers,
Bert






-- Bert

Bert Gunter
Genentech Nonclinical Biostatistics
(650) 467-7374

"Data is not information. Information is not knowledge. And knowledge
is certainly not wisdom."
H. Gilbert Welch




On Thu, May 8, 2014 at 5:56 PM, Spencer Graves
<[hidden email]> wrote:

>           "as.character.call" seems not to work as an alias for deparse.
> Consider the following:
>
>
> xDy <- quote(x$y)
> class(xDy)
> "call"
> as.character.call <- function(x, ...)deparse(x, ...)
> as.character(xDy)
> [1] "$" "x" "y"
> # fails
>
> str(xDy)
> #  language x$y
> as.character.language <- function(x, ...)"language"
>
> as.character(xDy)
> [1] "$" "x" "y"
>
>
>           Is it feasible to construct a method for "as.character" that works
> for objects of class "call"?
>
>
>           Thanks,
>           Spencer
>
>
> #################
>
>
> Thanks for the quick replies from Richard Heiberger, Greg Show & Bert
> Gunter.
>
>
>       Might it make sense to create as.character.call as an alias for
> deparse?
>
>
>       A few years ago, I wrote several functions like "predict.fd" as
> aliases for functions with less memorable names like "eval.fd".  Doing that
> made the "fda" package easier to use, at least for me ;-)
>
>
>       Thanks again,
>       Spencer
>
>
> On 5/7/2014 2:39 PM, Bert Gunter wrote:
>>
>> ... and
>>
>>> str(quote(x$y))
>>
>>   language x$y
>>
>>> as.list(quote(x$y))
>>
>> [[1]]
>> `$`
>>
>> [[2]]
>> x
>>
>> [[3]]
>> y
>>
>> ## may be instructive.
>>
>> Cheers,
>> Bert
>>
>>
>>
>>
>> Bert Gunter
>> Genentech Nonclinical Biostatistics
>> (650) 467-7374
>>
>> "Data is not information. Information is not knowledge. And knowledge
>> is certainly not wisdom."
>> H. Gilbert Welch
>>
>>
>>
>>
>> On Wed, May 7, 2014 at 2:30 PM, Greg Snow <[hidden email]> wrote:
>>>>
>>>> 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
>>> <[hidden email]> 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
>>>>
>>>>
>>>>
>>>> --
>>>> Gregory (Greg) L. Snow Ph.D.
>>>> [hidden email]
>>>>
>>>> ______________________________________________
>>>> [hidden email] 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.
>
>

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: as.character(quote(x$y) ) = "$" "x" "y" not "x$y"?

Spencer Graves-2
On 5/8/2014 8:05 PM, Bert Gunter wrote:

> [1] "x$y"
>
> Spencer:
>
> Does
>
> deparse(substitute(x$y))
> [1] "x$y"
>
> do what you want?


       No:  The problem is methods dispatch.  class(quote(x$y)) =
'call', but as.character(quote(x$y)) does NOT go to "as.character.call".


       deparse(quote(x$y)) returns the answer I want, as Greg Snow noted
earlier.


       However, it would be easier to remember if I could write
as.character(quote(x$y)) and get the same thing.


       With "as.character.call <- function(x, ...)deparse(x, ...)",
as.character.call(quote(x$y)) returns "x$y", as desired. However, the
methods dispatch one might naively expect fails, as noted above.


       Thanks,
       Spencer

> Cheers,
> Bert
>
>
>
>
>
>
> -- Bert
>
> Bert Gunter
> Genentech Nonclinical Biostatistics
> (650) 467-7374
>
> "Data is not information. Information is not knowledge. And knowledge
> is certainly not wisdom."
> H. Gilbert Welch
>
>
>
>
> On Thu, May 8, 2014 at 5:56 PM, Spencer Graves
> <[hidden email]> wrote:
>>            "as.character.call" seems not to work as an alias for deparse.
>> Consider the following:
>>
>>
>> xDy <- quote(x$y)
>> class(xDy)
>> "call"
>> as.character.call <- function(x, ...)deparse(x, ...)
>> as.character(xDy)
>> [1] "$" "x" "y"
>> # fails
>>
>> str(xDy)
>> #  language x$y
>> as.character.language <- function(x, ...)"language"
>>
>> as.character(xDy)
>> [1] "$" "x" "y"
>>
>>
>>            Is it feasible to construct a method for "as.character" that works
>> for objects of class "call"?
>>
>>
>>            Thanks,
>>            Spencer
>>
>>
>> #################
>>
>>
>> Thanks for the quick replies from Richard Heiberger, Greg Show & Bert
>> Gunter.
>>
>>
>>        Might it make sense to create as.character.call as an alias for
>> deparse?
>>
>>
>>        A few years ago, I wrote several functions like "predict.fd" as
>> aliases for functions with less memorable names like "eval.fd".  Doing that
>> made the "fda" package easier to use, at least for me ;-)
>>
>>
>>        Thanks again,
>>        Spencer
>>
>>
>> On 5/7/2014 2:39 PM, Bert Gunter wrote:
>>> ... and
>>>
>>>> str(quote(x$y))
>>>    language x$y
>>>
>>>> as.list(quote(x$y))
>>> [[1]]
>>> `$`
>>>
>>> [[2]]
>>> x
>>>
>>> [[3]]
>>> y
>>>
>>> ## may be instructive.
>>>
>>> Cheers,
>>> Bert
>>>
>>>
>>>
>>>
>>> Bert Gunter
>>> Genentech Nonclinical Biostatistics
>>> (650) 467-7374
>>>
>>> "Data is not information. Information is not knowledge. And knowledge
>>> is certainly not wisdom."
>>> H. Gilbert Welch
>>>
>>>
>>>
>>>
>>> On Wed, May 7, 2014 at 2:30 PM, Greg Snow <[hidden email]> wrote:
>>>>> 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
>>>> <[hidden email]> 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
>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> Gregory (Greg) L. Snow Ph.D.
>>>>> [hidden email]
>>>>>
>>>>> ______________________________________________
>>>>> [hidden email] 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.
>>
>


--
Spencer Graves, PE, PhD
President and Chief Technology Officer
Structure Inspection and Monitoring, Inc.
751 Emerson Ct.
San José, CA 95126
ph:  408-655-4567
web:  www.structuremonitoring.com

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: as.character(quote(x$y) ) = "$" "x" "y" not "x$y"?

Bert Gunter
Spencer:

Hmmm....
Well, I don't get what's going on here -- as.character.default is
internal -- but could you method-ize a simple synonym:

asChar<- function(e,...)UseMethod("asChar")
asChar.call <- function(e,...)deparse(e,...)
asChar.default <- function(e,...)as.character(e,...)

> asChar(xDy)
[1] "x$y"

> asChar(1:5)
[1] "1" "2" "3" "4" "5"


Cheers,
Bert

Bert Gunter
Genentech Nonclinical Biostatistics
(650) 467-7374

"Data is not information. Information is not knowledge. And knowledge
is certainly not wisdom."
H. Gilbert Welch




On Thu, May 8, 2014 at 8:56 PM, Spencer Graves
<[hidden email]> wrote:

> On 5/8/2014 8:05 PM, Bert Gunter wrote:
>>
>> [1] "x$y"
>>
>> Spencer:
>>
>> Does
>>
>> deparse(substitute(x$y))
>> [1] "x$y"
>>
>> do what you want?
>
>
>
>       No:  The problem is methods dispatch.  class(quote(x$y)) = 'call', but
> as.character(quote(x$y)) does NOT go to "as.character.call".
>
>
>       deparse(quote(x$y)) returns the answer I want, as Greg Snow noted
> earlier.
>
>
>       However, it would be easier to remember if I could write
> as.character(quote(x$y)) and get the same thing.
>
>
>       With "as.character.call <- function(x, ...)deparse(x, ...)",
> as.character.call(quote(x$y)) returns "x$y", as desired. However, the
> methods dispatch one might naively expect fails, as noted above.
>
>
>       Thanks,
>       Spencer
>
>> Cheers,
>> Bert
>>
>>
>>
>>
>>
>>
>> -- Bert
>>
>> Bert Gunter
>> Genentech Nonclinical Biostatistics
>> (650) 467-7374
>>
>> "Data is not information. Information is not knowledge. And knowledge
>> is certainly not wisdom."
>> H. Gilbert Welch
>>
>>
>>
>>
>> On Thu, May 8, 2014 at 5:56 PM, Spencer Graves
>> <[hidden email]> wrote:
>>>
>>>            "as.character.call" seems not to work as an alias for deparse.
>>> Consider the following:
>>>
>>>
>>> xDy <- quote(x$y)
>>> class(xDy)
>>> "call"
>>> as.character.call <- function(x, ...)deparse(x, ...)
>>> as.character(xDy)
>>> [1] "$" "x" "y"
>>> # fails
>>>
>>> str(xDy)
>>> #  language x$y
>>> as.character.language <- function(x, ...)"language"
>>>
>>> as.character(xDy)
>>> [1] "$" "x" "y"
>>>
>>>
>>>            Is it feasible to construct a method for "as.character" that
>>> works
>>> for objects of class "call"?
>>>
>>>
>>>            Thanks,
>>>            Spencer
>>>
>>>
>>> #################
>>>
>>>
>>> Thanks for the quick replies from Richard Heiberger, Greg Show & Bert
>>> Gunter.
>>>
>>>
>>>        Might it make sense to create as.character.call as an alias for
>>> deparse?
>>>
>>>
>>>        A few years ago, I wrote several functions like "predict.fd" as
>>> aliases for functions with less memorable names like "eval.fd".  Doing
>>> that
>>> made the "fda" package easier to use, at least for me ;-)
>>>
>>>
>>>        Thanks again,
>>>        Spencer
>>>
>>>
>>> On 5/7/2014 2:39 PM, Bert Gunter wrote:
>>>>
>>>> ... and
>>>>
>>>>> str(quote(x$y))
>>>>
>>>>    language x$y
>>>>
>>>>> as.list(quote(x$y))
>>>>
>>>> [[1]]
>>>> `$`
>>>>
>>>> [[2]]
>>>> x
>>>>
>>>> [[3]]
>>>> y
>>>>
>>>> ## may be instructive.
>>>>
>>>> Cheers,
>>>> Bert
>>>>
>>>>
>>>>
>>>>
>>>> Bert Gunter
>>>> Genentech Nonclinical Biostatistics
>>>> (650) 467-7374
>>>>
>>>> "Data is not information. Information is not knowledge. And knowledge
>>>> is certainly not wisdom."
>>>> H. Gilbert Welch
>>>>
>>>>
>>>>
>>>>
>>>> On Wed, May 7, 2014 at 2:30 PM, Greg Snow <[hidden email]> wrote:
>>>>>>
>>>>>> 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
>>>>> <[hidden email]> 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
>>>>>>
>>>>>>
>>>>>>
>>>>>> --
>>>>>> Gregory (Greg) L. Snow Ph.D.
>>>>>> [hidden email]
>>>>>>
>>>>>> ______________________________________________
>>>>>> [hidden email] 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.
>>>
>>>
>>
>
>
> --
> Spencer Graves, PE, PhD
> President and Chief Technology Officer
> Structure Inspection and Monitoring, Inc.
> 751 Emerson Ct.
> San José, CA 95126
> ph:  408-655-4567
> web:  www.structuremonitoring.com
>

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: as.character(quote(x$y) ) = "$" "x" "y" not "x$y"?

Duncan Murdoch-2
On 09/05/2014, 2:41 AM, Bert Gunter wrote:
> Spencer:
>
> Hmmm....
> Well, I don't get what's going on here -- as.character.default is
> internal -- but could you method-ize a simple synonym:

See ?InternalMethods:

"For efficiency, internal dispatch only occurs on objects, that is those
for which is.object returns true."

Duncan Murdoch


>
> asChar<- function(e,...)UseMethod("asChar")
> asChar.call <- function(e,...)deparse(e,...)
> asChar.default <- function(e,...)as.character(e,...)
>
>> asChar(xDy)
> [1] "x$y"
>
>> asChar(1:5)
> [1] "1" "2" "3" "4" "5"
>
>
> Cheers,
> Bert
>
> Bert Gunter
> Genentech Nonclinical Biostatistics
> (650) 467-7374
>
> "Data is not information. Information is not knowledge. And knowledge
> is certainly not wisdom."
> H. Gilbert Welch
>
>
>
>
> On Thu, May 8, 2014 at 8:56 PM, Spencer Graves
> <[hidden email]> wrote:
>> On 5/8/2014 8:05 PM, Bert Gunter wrote:
>>>
>>> [1] "x$y"
>>>
>>> Spencer:
>>>
>>> Does
>>>
>>> deparse(substitute(x$y))
>>> [1] "x$y"
>>>
>>> do what you want?
>>
>>
>>
>>        No:  The problem is methods dispatch.  class(quote(x$y)) = 'call', but
>> as.character(quote(x$y)) does NOT go to "as.character.call".
>>
>>
>>        deparse(quote(x$y)) returns the answer I want, as Greg Snow noted
>> earlier.
>>
>>
>>        However, it would be easier to remember if I could write
>> as.character(quote(x$y)) and get the same thing.
>>
>>
>>        With "as.character.call <- function(x, ...)deparse(x, ...)",
>> as.character.call(quote(x$y)) returns "x$y", as desired. However, the
>> methods dispatch one might naively expect fails, as noted above.
>>
>>
>>        Thanks,
>>        Spencer
>>
>>> Cheers,
>>> Bert
>>>
>>>
>>>
>>>
>>>
>>>
>>> -- Bert
>>>
>>> Bert Gunter
>>> Genentech Nonclinical Biostatistics
>>> (650) 467-7374
>>>
>>> "Data is not information. Information is not knowledge. And knowledge
>>> is certainly not wisdom."
>>> H. Gilbert Welch
>>>
>>>
>>>
>>>
>>> On Thu, May 8, 2014 at 5:56 PM, Spencer Graves
>>> <[hidden email]> wrote:
>>>>
>>>>             "as.character.call" seems not to work as an alias for deparse.
>>>> Consider the following:
>>>>
>>>>
>>>> xDy <- quote(x$y)
>>>> class(xDy)
>>>> "call"
>>>> as.character.call <- function(x, ...)deparse(x, ...)
>>>> as.character(xDy)
>>>> [1] "$" "x" "y"
>>>> # fails
>>>>
>>>> str(xDy)
>>>> #  language x$y
>>>> as.character.language <- function(x, ...)"language"
>>>>
>>>> as.character(xDy)
>>>> [1] "$" "x" "y"
>>>>
>>>>
>>>>             Is it feasible to construct a method for "as.character" that
>>>> works
>>>> for objects of class "call"?
>>>>
>>>>
>>>>             Thanks,
>>>>             Spencer
>>>>
>>>>
>>>> #################
>>>>
>>>>
>>>> Thanks for the quick replies from Richard Heiberger, Greg Show & Bert
>>>> Gunter.
>>>>
>>>>
>>>>         Might it make sense to create as.character.call as an alias for
>>>> deparse?
>>>>
>>>>
>>>>         A few years ago, I wrote several functions like "predict.fd" as
>>>> aliases for functions with less memorable names like "eval.fd".  Doing
>>>> that
>>>> made the "fda" package easier to use, at least for me ;-)
>>>>
>>>>
>>>>         Thanks again,
>>>>         Spencer
>>>>
>>>>
>>>> On 5/7/2014 2:39 PM, Bert Gunter wrote:
>>>>>
>>>>> ... and
>>>>>
>>>>>> str(quote(x$y))
>>>>>
>>>>>     language x$y
>>>>>
>>>>>> as.list(quote(x$y))
>>>>>
>>>>> [[1]]
>>>>> `$`
>>>>>
>>>>> [[2]]
>>>>> x
>>>>>
>>>>> [[3]]
>>>>> y
>>>>>
>>>>> ## may be instructive.
>>>>>
>>>>> Cheers,
>>>>> Bert
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> Bert Gunter
>>>>> Genentech Nonclinical Biostatistics
>>>>> (650) 467-7374
>>>>>
>>>>> "Data is not information. Information is not knowledge. And knowledge
>>>>> is certainly not wisdom."
>>>>> H. Gilbert Welch
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> On Wed, May 7, 2014 at 2:30 PM, Greg Snow <[hidden email]> wrote:
>>>>>>>
>>>>>>> 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
>>>>>> <[hidden email]> 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
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> --
>>>>>>> Gregory (Greg) L. Snow Ph.D.
>>>>>>> [hidden email]
>>>>>>>
>>>>>>> ______________________________________________
>>>>>>> [hidden email] 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.
>>>>
>>>>
>>>
>>
>>
>> --
>> Spencer Graves, PE, PhD
>> President and Chief Technology Officer
>> Structure Inspection and Monitoring, Inc.
>> 751 Emerson Ct.
>> San José, CA 95126
>> ph:  408-655-4567
>> web:  www.structuremonitoring.com
>>
>
> ______________________________________________
> [hidden email] 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.
>

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: as.character(quote(x$y) ) = "$" "x" "y" not "x$y"?

Bert Gunter
Ahhh. Thanks Duncan.

-- Bert

Bert Gunter
Genentech Nonclinical Biostatistics
(650) 467-7374

"Data is not information. Information is not knowledge. And knowledge
is certainly not wisdom."
H. Gilbert Welch




On Fri, May 9, 2014 at 2:41 AM, Duncan Murdoch <[hidden email]> wrote:

> On 09/05/2014, 2:41 AM, Bert Gunter wrote:
>>
>> Spencer:
>>
>> Hmmm....
>> Well, I don't get what's going on here -- as.character.default is
>> internal -- but could you method-ize a simple synonym:
>
>
> See ?InternalMethods:
>
> "For efficiency, internal dispatch only occurs on objects, that is those for
> which is.object returns true."
>
> Duncan Murdoch
>
>
>>
>> asChar<- function(e,...)UseMethod("asChar")
>> asChar.call <- function(e,...)deparse(e,...)
>> asChar.default <- function(e,...)as.character(e,...)
>>
>>> asChar(xDy)
>>
>> [1] "x$y"
>>
>>> asChar(1:5)
>>
>> [1] "1" "2" "3" "4" "5"
>>
>>
>> Cheers,
>> Bert
>>
>> Bert Gunter
>> Genentech Nonclinical Biostatistics
>> (650) 467-7374
>>
>> "Data is not information. Information is not knowledge. And knowledge
>> is certainly not wisdom."
>> H. Gilbert Welch
>>
>>
>>
>>
>> On Thu, May 8, 2014 at 8:56 PM, Spencer Graves
>> <[hidden email]> wrote:
>>>
>>> On 5/8/2014 8:05 PM, Bert Gunter wrote:
>>>>
>>>>
>>>> [1] "x$y"
>>>>
>>>> Spencer:
>>>>
>>>> Does
>>>>
>>>> deparse(substitute(x$y))
>>>> [1] "x$y"
>>>>
>>>> do what you want?
>>>
>>>
>>>
>>>
>>>        No:  The problem is methods dispatch.  class(quote(x$y)) = 'call',
>>> but
>>> as.character(quote(x$y)) does NOT go to "as.character.call".
>>>
>>>
>>>        deparse(quote(x$y)) returns the answer I want, as Greg Snow noted
>>> earlier.
>>>
>>>
>>>        However, it would be easier to remember if I could write
>>> as.character(quote(x$y)) and get the same thing.
>>>
>>>
>>>        With "as.character.call <- function(x, ...)deparse(x, ...)",
>>> as.character.call(quote(x$y)) returns "x$y", as desired. However, the
>>> methods dispatch one might naively expect fails, as noted above.
>>>
>>>
>>>        Thanks,
>>>        Spencer
>>>
>>>> Cheers,
>>>> Bert
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> -- Bert
>>>>
>>>> Bert Gunter
>>>> Genentech Nonclinical Biostatistics
>>>> (650) 467-7374
>>>>
>>>> "Data is not information. Information is not knowledge. And knowledge
>>>> is certainly not wisdom."
>>>> H. Gilbert Welch
>>>>
>>>>
>>>>
>>>>
>>>> On Thu, May 8, 2014 at 5:56 PM, Spencer Graves
>>>> <[hidden email]> wrote:
>>>>>
>>>>>
>>>>>             "as.character.call" seems not to work as an alias for
>>>>> deparse.
>>>>> Consider the following:
>>>>>
>>>>>
>>>>> xDy <- quote(x$y)
>>>>> class(xDy)
>>>>> "call"
>>>>> as.character.call <- function(x, ...)deparse(x, ...)
>>>>> as.character(xDy)
>>>>> [1] "$" "x" "y"
>>>>> # fails
>>>>>
>>>>> str(xDy)
>>>>> #  language x$y
>>>>> as.character.language <- function(x, ...)"language"
>>>>>
>>>>> as.character(xDy)
>>>>> [1] "$" "x" "y"
>>>>>
>>>>>
>>>>>             Is it feasible to construct a method for "as.character"
>>>>> that
>>>>> works
>>>>> for objects of class "call"?
>>>>>
>>>>>
>>>>>             Thanks,
>>>>>             Spencer
>>>>>
>>>>>
>>>>> #################
>>>>>
>>>>>
>>>>> Thanks for the quick replies from Richard Heiberger, Greg Show & Bert
>>>>> Gunter.
>>>>>
>>>>>
>>>>>         Might it make sense to create as.character.call as an alias for
>>>>> deparse?
>>>>>
>>>>>
>>>>>         A few years ago, I wrote several functions like "predict.fd" as
>>>>> aliases for functions with less memorable names like "eval.fd".  Doing
>>>>> that
>>>>> made the "fda" package easier to use, at least for me ;-)
>>>>>
>>>>>
>>>>>         Thanks again,
>>>>>         Spencer
>>>>>
>>>>>
>>>>> On 5/7/2014 2:39 PM, Bert Gunter wrote:
>>>>>>
>>>>>>
>>>>>> ... and
>>>>>>
>>>>>>> str(quote(x$y))
>>>>>>
>>>>>>
>>>>>>     language x$y
>>>>>>
>>>>>>> as.list(quote(x$y))
>>>>>>
>>>>>>
>>>>>> [[1]]
>>>>>> `$`
>>>>>>
>>>>>> [[2]]
>>>>>> x
>>>>>>
>>>>>> [[3]]
>>>>>> y
>>>>>>
>>>>>> ## may be instructive.
>>>>>>
>>>>>> Cheers,
>>>>>> Bert
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> Bert Gunter
>>>>>> Genentech Nonclinical Biostatistics
>>>>>> (650) 467-7374
>>>>>>
>>>>>> "Data is not information. Information is not knowledge. And knowledge
>>>>>> is certainly not wisdom."
>>>>>> H. Gilbert Welch
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> On Wed, May 7, 2014 at 2:30 PM, Greg Snow <[hidden email]> wrote:
>>>>>>>>
>>>>>>>>
>>>>>>>> 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
>>>>>>> <[hidden email]> 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
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> --
>>>>>>>> Gregory (Greg) L. Snow Ph.D.
>>>>>>>> [hidden email]
>>>>>>>>
>>>>>>>> ______________________________________________
>>>>>>>> [hidden email] 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.
>>>>>
>>>>>
>>>>>
>>>>
>>>
>>>
>>> --
>>> Spencer Graves, PE, PhD
>>> President and Chief Technology Officer
>>> Structure Inspection and Monitoring, Inc.
>>> 751 Emerson Ct.
>>> San José, CA 95126
>>> ph:  408-655-4567
>>> web:  www.structuremonitoring.com
>>>
>>
>> ______________________________________________
>> [hidden email] 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.
>>
>

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: as.character(quote(x$y) ) = "$" "x" "y" not "x$y"?

Spencer Graves-2
Hi, Duncan:


       Thanks very much.  I used to think that everything in R was a
object.  Now I know that is.object(quote(x)) is FALSE.  (A decade ago,
S-Plus asked me if I wanted to save changes to history.  I thought,
"Wow!  Do I get to change history?"


       Hadley's "Advanced R" book mentions "Reference classes" in his
"OO field guide".  It includes an example where changing "a" changes a
"copy" previously made:


b <- a
b$balance
#> [1] 200
a$balance <- 0
b$balance
#> [1] 0


       This bothers me far more than an object in R that's not an object
;-)


       Best Wishes,
       Spencer


On 5/9/2014 6:48 AM, Bert Gunter wrote:

> Ahhh. Thanks Duncan.
>
> -- Bert
>
> Bert Gunter
> Genentech Nonclinical Biostatistics
> (650) 467-7374
>
> "Data is not information. Information is not knowledge. And knowledge
> is certainly not wisdom."
> H. Gilbert Welch
>
>
>
>
> On Fri, May 9, 2014 at 2:41 AM, Duncan Murdoch <[hidden email]> wrote:
>> On 09/05/2014, 2:41 AM, Bert Gunter wrote:
>>> Spencer:
>>>
>>> Hmmm....
>>> Well, I don't get what's going on here -- as.character.default is
>>> internal -- but could you method-ize a simple synonym:
>>
>> See ?InternalMethods:
>>
>> "For efficiency, internal dispatch only occurs on objects, that is those for
>> which is.object returns true."
>>
>> Duncan Murdoch
>>
>>
>>> asChar<- function(e,...)UseMethod("asChar")
>>> asChar.call <- function(e,...)deparse(e,...)
>>> asChar.default <- function(e,...)as.character(e,...)
>>>
>>>> asChar(xDy)
>>> [1] "x$y"
>>>
>>>> asChar(1:5)
>>> [1] "1" "2" "3" "4" "5"
>>>
>>>
>>> Cheers,
>>> Bert
>>>
>>> Bert Gunter
>>> Genentech Nonclinical Biostatistics
>>> (650) 467-7374
>>>
>>> "Data is not information. Information is not knowledge. And knowledge
>>> is certainly not wisdom."
>>> H. Gilbert Welch
>>>
>>>
>>>
>>>
>>> On Thu, May 8, 2014 at 8:56 PM, Spencer Graves
>>> <[hidden email]> wrote:
>>>> On 5/8/2014 8:05 PM, Bert Gunter wrote:
>>>>>
>>>>> [1] "x$y"
>>>>>
>>>>> Spencer:
>>>>>
>>>>> Does
>>>>>
>>>>> deparse(substitute(x$y))
>>>>> [1] "x$y"
>>>>>
>>>>> do what you want?
>>>>
>>>>
>>>>
>>>>         No:  The problem is methods dispatch.  class(quote(x$y)) = 'call',
>>>> but
>>>> as.character(quote(x$y)) does NOT go to "as.character.call".
>>>>
>>>>
>>>>         deparse(quote(x$y)) returns the answer I want, as Greg Snow noted
>>>> earlier.
>>>>
>>>>
>>>>         However, it would be easier to remember if I could write
>>>> as.character(quote(x$y)) and get the same thing.
>>>>
>>>>
>>>>         With "as.character.call <- function(x, ...)deparse(x, ...)",
>>>> as.character.call(quote(x$y)) returns "x$y", as desired. However, the
>>>> methods dispatch one might naively expect fails, as noted above.
>>>>
>>>>
>>>>         Thanks,
>>>>         Spencer
>>>>
>>>>> Cheers,
>>>>> Bert
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> -- Bert
>>>>>
>>>>> Bert Gunter
>>>>> Genentech Nonclinical Biostatistics
>>>>> (650) 467-7374
>>>>>
>>>>> "Data is not information. Information is not knowledge. And knowledge
>>>>> is certainly not wisdom."
>>>>> H. Gilbert Welch
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> On Thu, May 8, 2014 at 5:56 PM, Spencer Graves
>>>>> <[hidden email]> wrote:
>>>>>>
>>>>>>              "as.character.call" seems not to work as an alias for
>>>>>> deparse.
>>>>>> Consider the following:
>>>>>>
>>>>>>
>>>>>> xDy <- quote(x$y)
>>>>>> class(xDy)
>>>>>> "call"
>>>>>> as.character.call <- function(x, ...)deparse(x, ...)
>>>>>> as.character(xDy)
>>>>>> [1] "$" "x" "y"
>>>>>> # fails
>>>>>>
>>>>>> str(xDy)
>>>>>> #  language x$y
>>>>>> as.character.language <- function(x, ...)"language"
>>>>>>
>>>>>> as.character(xDy)
>>>>>> [1] "$" "x" "y"
>>>>>>
>>>>>>
>>>>>>              Is it feasible to construct a method for "as.character"
>>>>>> that
>>>>>> works
>>>>>> for objects of class "call"?
>>>>>>
>>>>>>
>>>>>>              Thanks,
>>>>>>              Spencer
>>>>>>
>>>>>>
>>>>>> #################
>>>>>>
>>>>>>
>>>>>> Thanks for the quick replies from Richard Heiberger, Greg Show & Bert
>>>>>> Gunter.
>>>>>>
>>>>>>
>>>>>>          Might it make sense to create as.character.call as an alias for
>>>>>> deparse?
>>>>>>
>>>>>>
>>>>>>          A few years ago, I wrote several functions like "predict.fd" as
>>>>>> aliases for functions with less memorable names like "eval.fd".  Doing
>>>>>> that
>>>>>> made the "fda" package easier to use, at least for me ;-)
>>>>>>
>>>>>>
>>>>>>          Thanks again,
>>>>>>          Spencer
>>>>>>
>>>>>>
>>>>>> On 5/7/2014 2:39 PM, Bert Gunter wrote:
>>>>>>>
>>>>>>> ... and
>>>>>>>
>>>>>>>> str(quote(x$y))
>>>>>>>
>>>>>>>      language x$y
>>>>>>>
>>>>>>>> as.list(quote(x$y))
>>>>>>>
>>>>>>> [[1]]
>>>>>>> `$`
>>>>>>>
>>>>>>> [[2]]
>>>>>>> x
>>>>>>>
>>>>>>> [[3]]
>>>>>>> y
>>>>>>>
>>>>>>> ## may be instructive.
>>>>>>>
>>>>>>> Cheers,
>>>>>>> Bert
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> Bert Gunter
>>>>>>> Genentech Nonclinical Biostatistics
>>>>>>> (650) 467-7374
>>>>>>>
>>>>>>> "Data is not information. Information is not knowledge. And knowledge
>>>>>>> is certainly not wisdom."
>>>>>>> H. Gilbert Welch
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> On Wed, May 7, 2014 at 2:30 PM, Greg Snow <[hidden email]> wrote:
>>>>>>>>>
>>>>>>>>> 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
>>>>>>>> <[hidden email]> 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
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> --
>>>>>>>>> Gregory (Greg) L. Snow Ph.D.
>>>>>>>>> [hidden email]
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> ______________________________________________
>>>>>>>>> [hidden email] 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.
>>>>>>>>>

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: as.character(quote(x$y) ) = "$" "x" "y" not "x$y"?

hadley wickham
Beware of the is.* functions:

* is.object() does not test the usual definition of objects
* is.vector() does not test the usual definition of vectors
* is.numeric() does not work the same way as is.character() or is.integer()
* is.Date() doesn't exist
* is.nan() doesn't return TRUE for some NaNs

Hadley

On Fri, May 9, 2014 at 4:32 PM, Spencer Graves
<[hidden email]> wrote:

> Hi, Duncan:
>
>
>       Thanks very much.  I used to think that everything in R was a object.
> Now I know that is.object(quote(x)) is FALSE.  (A decade ago, S-Plus asked
> me if I wanted to save changes to history.  I thought, "Wow!  Do I get to
> change history?"
>
>
>       Hadley's "Advanced R" book mentions "Reference classes" in his "OO
> field guide".  It includes an example where changing "a" changes a "copy"
> previously made:
>
>
> b <- a
> b$balance
> #> [1] 200
> a$balance <- 0
> b$balance
> #> [1] 0
>
>
>       This bothers me far more than an object in R that's not an object ;-)
>
>
>       Best Wishes,
>       Spencer
>
>
>
> On 5/9/2014 6:48 AM, Bert Gunter wrote:
>>
>> Ahhh. Thanks Duncan.
>>
>> -- Bert
>>
>> Bert Gunter
>> Genentech Nonclinical Biostatistics
>> (650) 467-7374
>>
>> "Data is not information. Information is not knowledge. And knowledge
>> is certainly not wisdom."
>> H. Gilbert Welch
>>
>>
>>
>>
>> On Fri, May 9, 2014 at 2:41 AM, Duncan Murdoch <[hidden email]>
>> wrote:
>>>
>>> On 09/05/2014, 2:41 AM, Bert Gunter wrote:
>>>>
>>>> Spencer:
>>>>
>>>> Hmmm....
>>>> Well, I don't get what's going on here -- as.character.default is
>>>> internal -- but could you method-ize a simple synonym:
>>>
>>>
>>> See ?InternalMethods:
>>>
>>> "For efficiency, internal dispatch only occurs on objects, that is those
>>> for
>>> which is.object returns true."
>>>
>>> Duncan Murdoch
>>>
>>>
>>>> asChar<- function(e,...)UseMethod("asChar")
>>>> asChar.call <- function(e,...)deparse(e,...)
>>>> asChar.default <- function(e,...)as.character(e,...)
>>>>
>>>>> asChar(xDy)
>>>>
>>>> [1] "x$y"
>>>>
>>>>> asChar(1:5)
>>>>
>>>> [1] "1" "2" "3" "4" "5"
>>>>
>>>>
>>>> Cheers,
>>>> Bert
>>>>
>>>> Bert Gunter
>>>> Genentech Nonclinical Biostatistics
>>>> (650) 467-7374
>>>>
>>>> "Data is not information. Information is not knowledge. And knowledge
>>>> is certainly not wisdom."
>>>> H. Gilbert Welch
>>>>
>>>>
>>>>
>>>>
>>>> On Thu, May 8, 2014 at 8:56 PM, Spencer Graves
>>>> <[hidden email]> wrote:
>>>>>
>>>>> On 5/8/2014 8:05 PM, Bert Gunter wrote:
>>>>>>
>>>>>>
>>>>>> [1] "x$y"
>>>>>>
>>>>>> Spencer:
>>>>>>
>>>>>> Does
>>>>>>
>>>>>> deparse(substitute(x$y))
>>>>>> [1] "x$y"
>>>>>>
>>>>>> do what you want?
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>         No:  The problem is methods dispatch.  class(quote(x$y)) =
>>>>> 'call',
>>>>> but
>>>>> as.character(quote(x$y)) does NOT go to "as.character.call".
>>>>>
>>>>>
>>>>>         deparse(quote(x$y)) returns the answer I want, as Greg Snow
>>>>> noted
>>>>> earlier.
>>>>>
>>>>>
>>>>>         However, it would be easier to remember if I could write
>>>>> as.character(quote(x$y)) and get the same thing.
>>>>>
>>>>>
>>>>>         With "as.character.call <- function(x, ...)deparse(x, ...)",
>>>>> as.character.call(quote(x$y)) returns "x$y", as desired. However, the
>>>>> methods dispatch one might naively expect fails, as noted above.
>>>>>
>>>>>
>>>>>         Thanks,
>>>>>         Spencer
>>>>>
>>>>>> Cheers,
>>>>>> Bert
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> -- Bert
>>>>>>
>>>>>> Bert Gunter
>>>>>> Genentech Nonclinical Biostatistics
>>>>>> (650) 467-7374
>>>>>>
>>>>>> "Data is not information. Information is not knowledge. And knowledge
>>>>>> is certainly not wisdom."
>>>>>> H. Gilbert Welch
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> On Thu, May 8, 2014 at 5:56 PM, Spencer Graves
>>>>>> <[hidden email]> wrote:
>>>>>>>
>>>>>>>
>>>>>>>              "as.character.call" seems not to work as an alias for
>>>>>>> deparse.
>>>>>>> Consider the following:
>>>>>>>
>>>>>>>
>>>>>>> xDy <- quote(x$y)
>>>>>>> class(xDy)
>>>>>>> "call"
>>>>>>> as.character.call <- function(x, ...)deparse(x, ...)
>>>>>>> as.character(xDy)
>>>>>>> [1] "$" "x" "y"
>>>>>>> # fails
>>>>>>>
>>>>>>> str(xDy)
>>>>>>> #  language x$y
>>>>>>> as.character.language <- function(x, ...)"language"
>>>>>>>
>>>>>>> as.character(xDy)
>>>>>>> [1] "$" "x" "y"
>>>>>>>
>>>>>>>
>>>>>>>              Is it feasible to construct a method for "as.character"
>>>>>>> that
>>>>>>> works
>>>>>>> for objects of class "call"?
>>>>>>>
>>>>>>>
>>>>>>>              Thanks,
>>>>>>>              Spencer
>>>>>>>
>>>>>>>
>>>>>>> #################
>>>>>>>
>>>>>>>
>>>>>>> Thanks for the quick replies from Richard Heiberger, Greg Show & Bert
>>>>>>> Gunter.
>>>>>>>
>>>>>>>
>>>>>>>          Might it make sense to create as.character.call as an alias
>>>>>>> for
>>>>>>> deparse?
>>>>>>>
>>>>>>>
>>>>>>>          A few years ago, I wrote several functions like "predict.fd"
>>>>>>> as
>>>>>>> aliases for functions with less memorable names like "eval.fd".
>>>>>>> Doing
>>>>>>> that
>>>>>>> made the "fda" package easier to use, at least for me ;-)
>>>>>>>
>>>>>>>
>>>>>>>          Thanks again,
>>>>>>>          Spencer
>>>>>>>
>>>>>>>
>>>>>>> On 5/7/2014 2:39 PM, Bert Gunter wrote:
>>>>>>>>
>>>>>>>>
>>>>>>>> ... and
>>>>>>>>
>>>>>>>>> str(quote(x$y))
>>>>>>>>
>>>>>>>>
>>>>>>>>      language x$y
>>>>>>>>
>>>>>>>>> as.list(quote(x$y))
>>>>>>>>
>>>>>>>>
>>>>>>>> [[1]]
>>>>>>>> `$`
>>>>>>>>
>>>>>>>> [[2]]
>>>>>>>> x
>>>>>>>>
>>>>>>>> [[3]]
>>>>>>>> y
>>>>>>>>
>>>>>>>> ## may be instructive.
>>>>>>>>
>>>>>>>> Cheers,
>>>>>>>> Bert
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> Bert Gunter
>>>>>>>> Genentech Nonclinical Biostatistics
>>>>>>>> (650) 467-7374
>>>>>>>>
>>>>>>>> "Data is not information. Information is not knowledge. And
>>>>>>>> knowledge
>>>>>>>> is certainly not wisdom."
>>>>>>>> H. Gilbert Welch
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> On Wed, May 7, 2014 at 2:30 PM, Greg Snow <[hidden email]> wrote:
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> 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
>>>>>>>>> <[hidden email]> 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
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> --
>>>>>>>>>> Gregory (Greg) L. Snow Ph.D.
>>>>>>>>>> [hidden email]
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> ______________________________________________
>>>>>>>>>> [hidden email] 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.
>>>>>>>>>>
>
> ______________________________________________
> [hidden email] 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.



--
http://had.co.nz/

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: as.character(quote(x$y) ) = "$" "x" "y" not "x$y"?

Spencer Graves-2
Dear Hadley:


       Thanks for that.  Digits are not numbers.  Numbers are not data.  
Data is not information.  Information is not intelligence. Intelligence
is not knowledge.  Knowledge is not wisdom.  And your "is." warnings are
more useful than my trivia here.


       Spencer


On 5/9/2014 2:42 PM, Hadley Wickham wrote:

> Beware of the is.* functions:
>
> * is.object() does not test the usual definition of objects
> * is.vector() does not test the usual definition of vectors
> * is.numeric() does not work the same way as is.character() or is.integer()
> * is.Date() doesn't exist
> * is.nan() doesn't return TRUE for some NaNs
>
> Hadley
>
> On Fri, May 9, 2014 at 4:32 PM, Spencer Graves
> <[hidden email]> wrote:
>> Hi, Duncan:
>>
>>
>>        Thanks very much.  I used to think that everything in R was a object.
>> Now I know that is.object(quote(x)) is FALSE.  (A decade ago, S-Plus asked
>> me if I wanted to save changes to history.  I thought, "Wow!  Do I get to
>> change history?"
>>
>>
>>        Hadley's "Advanced R" book mentions "Reference classes" in his "OO
>> field guide".  It includes an example where changing "a" changes a "copy"
>> previously made:
>>
>>
>> b <- a
>> b$balance
>> #> [1] 200
>> a$balance <- 0
>> b$balance
>> #> [1] 0
>>
>>
>>        This bothers me far more than an object in R that's not an object ;-)
>>
>>
>>        Best Wishes,
>>        Spencer
>>
>>
>>
>> On 5/9/2014 6:48 AM, Bert Gunter wrote:
>>> Ahhh. Thanks Duncan.
>>>
>>> -- Bert
>>>
>>> Bert Gunter
>>> Genentech Nonclinical Biostatistics
>>> (650) 467-7374
>>>
>>> "Data is not information. Information is not knowledge. And knowledge
>>> is certainly not wisdom."
>>> H. Gilbert Welch
>>>
>>>
>>>
>>>
>>> On Fri, May 9, 2014 at 2:41 AM, Duncan Murdoch <[hidden email]>
>>> wrote:
>>>> On 09/05/2014, 2:41 AM, Bert Gunter wrote:
>>>>> Spencer:
>>>>>
>>>>> Hmmm....
>>>>> Well, I don't get what's going on here -- as.character.default is
>>>>> internal -- but could you method-ize a simple synonym:
>>>>
>>>> See ?InternalMethods:
>>>>
>>>> "For efficiency, internal dispatch only occurs on objects, that is those
>>>> for
>>>> which is.object returns true."
>>>>
>>>> Duncan Murdoch
>>>>
>>>>
>>>>> asChar<- function(e,...)UseMethod("asChar")
>>>>> asChar.call <- function(e,...)deparse(e,...)
>>>>> asChar.default <- function(e,...)as.character(e,...)
>>>>>
>>>>>> asChar(xDy)
>>>>> [1] "x$y"
>>>>>
>>>>>> asChar(1:5)
>>>>> [1] "1" "2" "3" "4" "5"
>>>>>
>>>>>
>>>>> Cheers,
>>>>> Bert
>>>>>
>>>>> Bert Gunter
>>>>> Genentech Nonclinical Biostatistics
>>>>> (650) 467-7374
>>>>>
>>>>> "Data is not information. Information is not knowledge. And knowledge
>>>>> is certainly not wisdom."
>>>>> H. Gilbert Welch
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> On Thu, May 8, 2014 at 8:56 PM, Spencer Graves
>>>>> <[hidden email]> wrote:
>>>>>> On 5/8/2014 8:05 PM, Bert Gunter wrote:
>>>>>>>
>>>>>>> [1] "x$y"
>>>>>>>
>>>>>>> Spencer:
>>>>>>>
>>>>>>> Does
>>>>>>>
>>>>>>> deparse(substitute(x$y))
>>>>>>> [1] "x$y"
>>>>>>>
>>>>>>> do what you want?
>>>>>>
>>>>>>
>>>>>>
>>>>>>          No:  The problem is methods dispatch.  class(quote(x$y)) =
>>>>>> 'call',
>>>>>> but
>>>>>> as.character(quote(x$y)) does NOT go to "as.character.call".
>>>>>>
>>>>>>
>>>>>>          deparse(quote(x$y)) returns the answer I want, as Greg Snow
>>>>>> noted
>>>>>> earlier.
>>>>>>
>>>>>>
>>>>>>          However, it would be easier to remember if I could write
>>>>>> as.character(quote(x$y)) and get the same thing.
>>>>>>
>>>>>>
>>>>>>          With "as.character.call <- function(x, ...)deparse(x, ...)",
>>>>>> as.character.call(quote(x$y)) returns "x$y", as desired. However, the
>>>>>> methods dispatch one might naively expect fails, as noted above.
>>>>>>
>>>>>>
>>>>>>          Thanks,
>>>>>>          Spencer
>>>>>>
>>>>>>> Cheers,
>>>>>>> Bert
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> -- Bert
>>>>>>>
>>>>>>> Bert Gunter
>>>>>>> Genentech Nonclinical Biostatistics
>>>>>>> (650) 467-7374
>>>>>>>
>>>>>>> "Data is not information. Information is not knowledge. And knowledge
>>>>>>> is certainly not wisdom."
>>>>>>> H. Gilbert Welch
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> On Thu, May 8, 2014 at 5:56 PM, Spencer Graves
>>>>>>> <[hidden email]> wrote:
>>>>>>>>
>>>>>>>>               "as.character.call" seems not to work as an alias for
>>>>>>>> deparse.
>>>>>>>> Consider the following:
>>>>>>>>
>>>>>>>>
>>>>>>>> xDy <- quote(x$y)
>>>>>>>> class(xDy)
>>>>>>>> "call"
>>>>>>>> as.character.call <- function(x, ...)deparse(x, ...)
>>>>>>>> as.character(xDy)
>>>>>>>> [1] "$" "x" "y"
>>>>>>>> # fails
>>>>>>>>
>>>>>>>> str(xDy)
>>>>>>>> #  language x$y
>>>>>>>> as.character.language <- function(x, ...)"language"
>>>>>>>>
>>>>>>>> as.character(xDy)
>>>>>>>> [1] "$" "x" "y"
>>>>>>>>
>>>>>>>>
>>>>>>>>               Is it feasible to construct a method for "as.character"
>>>>>>>> that
>>>>>>>> works
>>>>>>>> for objects of class "call"?
>>>>>>>>
>>>>>>>>
>>>>>>>>               Thanks,
>>>>>>>>               Spencer
>>>>>>>>
>>>>>>>>
>>>>>>>> #################
>>>>>>>>
>>>>>>>>
>>>>>>>> Thanks for the quick replies from Richard Heiberger, Greg Show & Bert
>>>>>>>> Gunter.
>>>>>>>>
>>>>>>>>
>>>>>>>>           Might it make sense to create as.character.call as an alias
>>>>>>>> for
>>>>>>>> deparse?
>>>>>>>>
>>>>>>>>
>>>>>>>>           A few years ago, I wrote several functions like "predict.fd"
>>>>>>>> as
>>>>>>>> aliases for functions with less memorable names like "eval.fd".
>>>>>>>> Doing
>>>>>>>> that
>>>>>>>> made the "fda" package easier to use, at least for me ;-)
>>>>>>>>
>>>>>>>>
>>>>>>>>           Thanks again,
>>>>>>>>           Spencer
>>>>>>>>
>>>>>>>>
>>>>>>>> On 5/7/2014 2:39 PM, Bert Gunter wrote:
>>>>>>>>>
>>>>>>>>> ... and
>>>>>>>>>
>>>>>>>>>> str(quote(x$y))
>>>>>>>>>
>>>>>>>>>       language x$y
>>>>>>>>>
>>>>>>>>>> as.list(quote(x$y))
>>>>>>>>>
>>>>>>>>> [[1]]
>>>>>>>>> `$`
>>>>>>>>>
>>>>>>>>> [[2]]
>>>>>>>>> x
>>>>>>>>>
>>>>>>>>> [[3]]
>>>>>>>>> y
>>>>>>>>>
>>>>>>>>> ## may be instructive.
>>>>>>>>>
>>>>>>>>> Cheers,
>>>>>>>>> Bert
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> Bert Gunter
>>>>>>>>> Genentech Nonclinical Biostatistics
>>>>>>>>> (650) 467-7374
>>>>>>>>>
>>>>>>>>> "Data is not information. Information is not knowledge. And
>>>>>>>>> knowledge
>>>>>>>>> is certainly not wisdom."
>>>>>>>>> H. Gilbert Welch
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> On Wed, May 7, 2014 at 2:30 PM, Greg Snow <[hidden email]> wrote:
>>>>>>>>>>>
>>>>>>>>>>> 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
>>>>>>>>>> <[hidden email]> 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
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> --
>>>>>>>>>>> Gregory (Greg) L. Snow Ph.D.
>>>>>>>>>>> [hidden email]
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> ______________________________________________
>>>>>>>>>>> [hidden email] 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.
>>>>>>>>>>>
>> ______________________________________________
>> [hidden email] 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.
>
>


--
Spencer Graves, PE, PhD
President and Chief Technology Officer
Structure Inspection and Monitoring, Inc.
751 Emerson Ct.
San José, CA 95126
ph:  408-655-4567
web:  www.structuremonitoring.com

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: as.character(quote(x$y) ) = "$" "x" "y" not "x$y"?

barry rowlingson
In reply to this post by Spencer Graves-2
On Fri, May 9, 2014 at 10:42 PM, Hadley Wickham <[hidden email]> wrote:
> Beware of the is.* functions:
>
> * is.object() does not test the usual definition of objects
> * is.vector() does not test the usual definition of vectors
> * is.numeric() does not work the same way as is.character() or is.integer()
> * is.Date() doesn't exist
> * is.nan() doesn't return TRUE for some NaNs

 Can we have an "is.is" function that tells us these things?

 > is.is(is.object)
   [1] FALSE
    Warning: is.object() does not test the usual definition of objects

 > is.is(is.is)
   [1] TRUE

 For further exploration, demo("is.things") creates a handy "is.ALL"
function that outputs the result of running a lot of is.X functions on
its argument.

Barry

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: as.character(quote(x$y) ) = "$" "x" "y" not "x$y"?

Duncan Murdoch-2
On 10/05/2014, 6:46 AM, Barry Rowlingson wrote:

> On Fri, May 9, 2014 at 10:42 PM, Hadley Wickham <[hidden email]> wrote:
>> Beware of the is.* functions:
>>
>> * is.object() does not test the usual definition of objects
>> * is.vector() does not test the usual definition of vectors
>> * is.numeric() does not work the same way as is.character() or is.integer()
>> * is.Date() doesn't exist
>> * is.nan() doesn't return TRUE for some NaNs
>
>   Can we have an "is.is" function that tells us these things?
>
>   > is.is(is.object)
>     [1] FALSE
>      Warning: is.object() does not test the usual definition of objects
>
>   > is.is(is.is)
>     [1] TRUE
>
>   For further exploration, demo("is.things") creates a handy "is.ALL"
> function that outputs the result of running a lot of is.X functions on
> its argument.

I tried to write it, but the trouble is, is.is(is.is) is FALSE.

Duncan

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: as.character(quote(x$y) ) = "$" "x" "y" not "x$y"?

Peter Dalgaard-2

On 10 May 2014, at 12:54 , Duncan Murdoch <[hidden email]> wrote:

> On 10/05/2014, 6:46 AM, Barry Rowlingson wrote:
>> On Fri, May 9, 2014 at 10:42 PM, Hadley Wickham <[hidden email]> wrote:
>>> Beware of the is.* functions:
>>>
>>> * is.object() does not test the usual definition of objects
>>> * is.vector() does not test the usual definition of vectors
>>> * is.numeric() does not work the same way as is.character() or is.integer()
>>> * is.Date() doesn't exist
>>> * is.nan() doesn't return TRUE for some NaNs
>>
>>  Can we have an "is.is" function that tells us these things?
>>
>>  > is.is(is.object)
>>    [1] FALSE
>>     Warning: is.object() does not test the usual definition of objects
>>
>>  > is.is(is.is)
>>    [1] TRUE
>>
>>  For further exploration, demo("is.things") creates a handy "is.ALL"
>> function that outputs the result of running a lot of is.X functions on
>> its argument.
>
> I tried to write it, but the trouble is, is.is(is.is) is FALSE.
>
> Duncan


Worse,

is.is(mybaby) | is.aint(mybaby)

comes out TRUE whatever the value of mybaby.

--
Peter Dalgaard, Professor,
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Email: [hidden email]  Priv: [hidden email]

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: as.character(quote(x$y) ) = "$" "x" "y" not "x$y"?

David Winsemius
In reply to this post by Duncan Murdoch-2

On May 10, 2014, at 3:54 AM, Duncan Murdoch wrote:

> On 10/05/2014, 6:46 AM, Barry Rowlingson wrote:
>> On Fri, May 9, 2014 at 10:42 PM, Hadley Wickham <[hidden email]> wrote:
>>> Beware of the is.* functions:
>>>
>>> * is.object() does not test the usual definition of objects
>>> * is.vector() does not test the usual definition of vectors
>>> * is.numeric() does not work the same way as is.character() or is.integer()
>>> * is.Date() doesn't exist
>>> * is.nan() doesn't return TRUE for some NaNs
>>
>>  Can we have an "is.is" function that tells us these things?
>>
>>  > is.is(is.object)
>>    [1] FALSE
>>     Warning: is.object() does not test the usual definition of objects
>>
>>  > is.is(is.is)
>>    [1] TRUE
>>
>>  For further exploration, demo("is.things") creates a handy "is.ALL"
>> function that outputs the result of running a lot of is.X functions on
>> its argument.
>
> I tried to write it, but the trouble is, is.is(is.is) is FALSE.

Perhaps the R engine will surmount the Singularity when `is.think`  returns `is.is`.

>
> Duncan
>



David Winsemius
Alameda, CA, USA

______________________________________________
[hidden email] 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.