Re: [R] Converting from char to POSIX:

From: Prof Brian Ripley <ripley_at_stats.ox.ac.uk>
Date: Mon, 28 Jul 2008 17:16:44 +0100 (BST)

On Mon, 28 Jul 2008, Agustin Lobo wrote:

> Given char vector delme2:
>> str(delme2)
> chr [1:1065] "30-1-08 8:48:21" "30-1-08 8:55:17" "30-1-08 9:00:22" ...
>
> I do:
>> delme3 <- strptime(delme2,format="%d-%m-%y %H:%M:%S")
>
> But then:
>> str(delme3)
> POSIXlt[1:9], format: "2008-01-30 08:48:21" "2008-01-30 08:55:17" ...
>> length(delme3)
> [1] 9
>
> whie
>
>> delme3[1065]
> [1] "2008-06-09 18:25:46"
>
> Where does the length 9 come from? How is it that I can get the 1065th

The list has nine elements: str() is confusiny you here. It's just the same as a data frame: that has (usually) few columns and many rows.

> element of delme3 if the length is just 9? How can I get a vector of POSIX
> elements with the same length as delme2 so that I can put it in a data.frame?

That must be a POSIXct vector, not a POSIXlt list.

> Thanks!
>
> Agus
> --
> Dr. Agustin Lobo
> Institut de Ciencies de la Terra "Jaume Almera" (CSIC)
> LLuis Sole Sabaris s/n
> 08028 Barcelona
> Spain
> Tel. 34 934095410
> Fax. 34 934110012
> email: Agustin.Lobo_at_ija.csic.es
> http://www.ija.csic.es/gt/obster
>
> ______________________________________________
> 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.
>

-- 
Brian D. Ripley,                  ripley_at_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_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.
Received on Mon 28 Jul 2008 - 16:25:32 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 Mon 28 Jul 2008 - 16:32:36 GMT.

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

list of date sections of archive