[R] problem with data

Prof Brian Ripley ripley at stats.ox.ac.uk
Thu Mar 8 14:55:24 CET 2012


On Thu, 8 Mar 2012, RMSOPS wrote:

> Hello
>
>   In the variable x.sub$Time i have the many dates in format  2006-10-31
> 20:10:35 EST, for example when
> print (x.sub$Time) give this
>
> [1] "2006-10-31 20:10:35 EST" "2006-10-31 20:11:08 EST" "2006-10-31 20:11:21
> EST" "2006-10-31 20:12:16 EST"
> [5] "2006-10-31 20:13:20 EST" "2006-10-31 20:13:28 EST" "2006-10-31
> 20:15:18 EST" "2006-10-31 20:16:06 EST"
>
> but when put in variable start the result in first position with code
> sart<-x.sub$Time[[1]], my goal by this code is save the
> result [1] "2006-10-31 20:10:35 EST".
>   The problem is the variable start give me  "[1]  35  8 21 16 20 28 18  6
> 40 17 52 15 13 12 23 10 39 40" when the goal is is to keep the original
> format  2006-10-31 20:10:35 EST.

Which I doubt was the original format, rather the way it is formatted 
for printing.

>  How solve this problem.

By following the posting guide ... without the information we asked 
for, we can only guess.

So here's a guess: x.sub$Time is an object of class POSIXlt, and you 
used [[1]] when you meant [1] .


> 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



More information about the R-help mailing list