Re: [R] how to get a histogram of an POSIXct vector ?

From: Prof Brian Ripley <ripley_at_stats.ox.ac.uk>
Date: Wed 23 Aug 2006 - 21:39:05 EST

On Wed, 23 Aug 2006, Peter.Marx@knorr-bremse.com wrote:

> Hi,
>
> search on web indicates that R also includes a hist method on POSIXct
> vectors.

> methods(hist)

[1] hist.Date* hist.default hist.POSIXt*

   Non-visible functions are asterisked

so almost (objects of class POSIXct inherit from class POSIXt).

> My (perhaps too unexperienced) approach below yields an error.
>
> Could somebody give me a hint what's wrong ?

samples is a data frame, not an object of class "POSIXct". Try hist(samples$DateTime).

(And thanks for giving enough detail to enable us to spot the problem.)

>
> Peter
>
>
> > str(samples)
> `data.frame': 7500 obs. of 1 variable:
> $ DateTime:'POSIXct', format: chr "2006-07-20 00:10:08" "2006-07-20
> 00:11:17" "2006-07-20 00:11:23"
>
> >hist(samples)
> Error in hist.default(samples) : 'x' must be numeric
>
> ______________________________________________
> R-help@stat.math.ethz.ch 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.
>

-- 
Brian D. Ripley,                  ripley@stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

______________________________________________
R-help@stat.math.ethz.ch 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.
Received on Thu Aug 24 01:03:48 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Thu 24 Aug 2006 - 02:22:47 EST.

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