R: Ordering and transforming irregular time strings -


i have similar problem following question on transforming irregular time strings. have time series of character class order.

r: transform irregular time strings

rather commas, milliseconds in separated ʻ.ʻ. however, when try apply gsub step, data replaced semi-colons.

head(time, n=5)

[1] "05:48:59.306" "05:48:56.246" "05:48:53.214" "05:48:52.662" "05:48:50.203"

time.new <- gsub(".", ":", time)

head(time.new, n=10)

[1] "::::::::::::" "::::::::::::" "::::::::::::" "::::::::::::" "::::::::::::"

if through step, in theory calculate decimal minutes column , order based on decimal minutes. missing gsub part? :p

any appreciated.

you should use 2 \ before . in gsub().

gsub("\\.", ":", time) 

Comments

Popular posts from this blog

html5 - What is breaking my page when printing? -

c# - must be a non-abstract type with a public parameterless constructor in redis -

ajax - PHP/JSON Login script (Twitter style) not setting sessions -