[R] Converting from char to POSIX:

Agustin Lobo aloboaleu at gmail.com
Mon Jul 28 14:14:12 CEST 2008


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 
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?

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



More information about the R-help mailing list