[R] trouble with extracting Date string from my data.

Gabor Grothendieck ggrothendieck at gmail.com
Mon Oct 15 19:40:15 CEST 2012


On Mon, Oct 15, 2012 at 12:32 PM, 박상규 <birdfire94 at naver.com> wrote:
> Hello,
>
> I have trouble with extracting Date string from my each row data.
>
> The date format I use is as the follows:
> ----------------------------------------------------------------------------
> -----------
> Index,Open,High,Low,Close # header
> 2011-11-01  9:00:00 ,248.50,248.95,248.20,248.70 ...
> ....
> ----------------------------------------------------------------------------
> -----------
>
> When I read the data with the below code,
>
> data_min1 <- as.xts(read.zoo("E://log.txt", sep=",", FUN=as.chron,
> header=TRUE))
>
> the result is as the follows:
>
>> head(data_min1)
>                       Open   High    Low  Close
> (11/01/11 09:00:00) 248.50 248.95 248.20 248.70
> (11/01/11 09:01:00) 248.70 249.00 248.65 248.85
> (11/01/11 09:02:00) 248.90 249.25 248.70 249.15
> (11/01/11 09:03:00) 249.20 249.60 249.10 249.60
> (11/01/11 09:04:00) 249.55 249.95 249.50 249.60
> (11/01/11 09:05:00) 249.60 249.85 249.55 249.75
>>
>
> I tried to extract Date object of each row(2011-11-01) and convert is as
> string("2011-11-01").
> But I couldn't.
>
> Could you help me ?
>

If you only want the Date part then omit FUN = as.chron since Date
class is the default.

-- 
Statistics & Software Consulting
GKX Group, GKX Associates Inc.
tel: 1-877-GKX-GROUP
email: ggrothendieck at gmail.com




More information about the R-help mailing list