How to format fractional seconds in POSIXct in r

Viewed 1563

I have read other questions regarding this topic but they do not seem to work on my dataset:

              Timestamp Bid.price Ask.price Bid.volume Ask.volume
 20070313 07:01:04:762  11.14122  11.14478   4.539397   1.891416
 20070313 07:01:07:608  11.13930  11.14670   1.277812   3.066750
 20070313 07:01:08:701  11.14095  11.14505   0.050396   0.050396
 20070313 07:01:11:275  11.14098  11.14502   0.226505   0.543613
 20070313 07:01:13:884  11.13930  11.14670   0.322856   0.774855
 20070313 07:01:16:588  11.13930  11.14670   0.405654   0.973569

I have tried:

as.POSIXct(fx[,1], format="%y%m%d %H:%M:%S:%OS3")
as.POSIXct(paste(fx[,1]), format="%y%m%d %H:%M:%S:%OS3")
as.POSIXct(paste(fx[,1]), format="%y%m%d %H:%M:%S")

but all I get are NAs ...

How do I work around this?

Here is the dataset:

fx <- structure(list(Timestamp = c("20070313 07:01:04:762", "20070313 07:01:07:608", 
"20070313 07:01:08:701", "20070313 07:01:11:275", "20070313 07:01:13:884", 
"20070313 07:01:16:588"), Bid.price = c(11.14122, 11.1393, 11.14095, 
11.14098, 11.1393, 11.1393), Ask.price = c(11.14478, 11.1467, 
11.14505, 11.14502, 11.1467, 11.1467), Bid.volume = c(4.5393967628479, 
1.27781200408936, 0.0503959991037846, 0.226504996418953, 0.3228560090065, 
0.405654013156891), Ask.volume = c(1.89141595363617, 3.06675004959106, 
0.0503959991037846, 0.543613016605377, 0.774855017662048, 0.973568975925446
)), .Names = c("Timestamp", "Bid.price", "Ask.price", "Bid.volume", 
"Ask.volume"), row.names = c(NA, 6L), class = "data.frame")
1 Answers
Related