Skip to content

text() does not accept data of type POSIXlt (PR#2487)

3 messages · wolfram at fischer-zim.ch, Brian Ripley

#
[R 1.6.1]

PROBLEM
    If text() is called with an argument of type POSIXlt,
    I get the following error message:

        "Error in as.double.default(x) :
        (list) object cannot be coerced to vector type 14"

REMARK
    plot() accepts this data.

EXAMPLE
    data( Lifeboats, package='vcd' )
    attach(Lifeboats)
    plot( launch, total )
    text( launch, total, labels=seq( along=as.vector( launch ) ) )
    detach(Lifeboats)


Wolfram Fischer
#
Where is the R bug here?

The dates are *NOT* `of type POSIXlt': they are of type list but
class c("POSIXt", "POSIXlt")

plot() is a generic function with a POSIXlt method.
text() has no POSIXt nor POSIXlt method.

Nothing says that an arbitrary function you choose will accept arbitrary 
input, nor that plot and points, lines, text etc will have compatible 
methods: there are dozens of exceptions.
On Wed, 22 Jan 2003 wolfram@fischer-zim.ch wrote:

            

  
    
#
Thanks for your hint about POSIXt and POSIXlt.

Excuse me that I bothered you with my message.

I thought that text() is a function which is used often in 
combination with plot(). I have the opinion that it would be
helpful if such functions are harmonised as good as possible. -
Therefore I took the time to inform about my observation.

Wolfram Fischer

--- In reply to: ---