[R] Problems with time formats when importing data using readHTMLTable

Jeff Newmiller jdnewmil at dcn.davis.ca.us
Mon Jul 10 18:18:05 CEST 2017


Not reproducible. [1][2][3] If our answers don't seem to apply to your situation, it will likely be because you did not explain your question clearly. 

Not plain text. This is a plain text mailing list,  and the best-case scenario when you let your email program send HTML is that what you saw is not what we see (worst case is your email is scrambled on our end).

Have you read the documentation for the function you are using? In particular, what about the colClasses argument? If you don't let readHTMLTable guess what the format is (have it read in as character data) then you have a fighting chance to get it right yourself, e.g.

as.POSIXct( "2017-07-10 14:04 (UTC)", format="%Y-%m-%d %H:%M (UTC)", tz="UTC" )

-----

[1] http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example

[2] http://adv-r.had.co.nz/Reproducibility.html

[3] https://cran.r-project.org/web/packages/reprex/index.html
-- 
Sent from my phone. Please excuse my brevity.

On July 10, 2017 8:31:30 AM PDT, Cristina Silva <csilva at ipma.pt> wrote:
>Hi,
>
>I am extracting positions data from the marine traffic website. The 
>table has a "Timestamp" column which, in the browser, appears with the 
>format yyyy-mm-dd HH:MM (UTC), e.g. 2017-07-10 14:04 (UTC).
>
>When I import the table, the same date "2017-07-10 14:04 (UTC)" appears
>
>as "1499696500149969650021 minutes ago", This is the more recent date 
>and time. Older records, as e.g. "2017-07-09 17:02 (UTC)" appear as
>e.g. 
>"1499619726149961972621 hours, 59 minutes ago".
>
>I don't know how to convert these data to the time formats used in R 
>(POSIXct).
>
>The script is very simple and worked before:
>
>library(XML)
>x <- readHTMLTable('url')
>
>where the 'url' is the link to the website with the specification of
>the 
>vessel.
>
>I appreciate any help.
>
>Cristina
>
>-- 
>Cristina Silva
>Divisão de Modelação e Gestão de Recursos Pesqueiros
>Av. Dr. Alfredo Magalhães Ramalho
>1495-165 Lisboa
>@: csilva at ipma.pt <mailto:csilva at ipma.pt>
>#: +351 213027096 <phoneto:+351213027096>
>
>
>	[[alternative HTML version deleted]]
>
>______________________________________________
>R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide
>http://www.R-project.org/posting-guide.html
>and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list