[R] Reading timestamp column from MySQL
Allan Engelhardt
allane at cybaea.com
Thu Jul 29 12:53:25 CEST 2010
On 29/07/10 00:20, harsh yadav wrote:
> Hi,
>
> I am reading a SQL (MySQL) table in R data frame.
>
> When I read in the table that has a timestamp data-type field, R gives it
> the following format:-
>
> 1.236887e+12
>
> So when I want to manipulate a column with timestamp = 1236887146615
>
> It returns me multiple rows, as many timestamps gets converted to same
> value: 1.236887e+12
>
> Any ideas of how this could be dealt with, so that I can get the entire
> timestamp field.
>
It should just be a printing issue, not a problem with the data, in
which case you can just run you analysis as usual. If it *is* an issue
with the data, and not the printing, then we probably need more
information, see the posting guide.
If you are worried about the formatting, look at options("scipen"); try
a value of 5 or so to get you started.
[*Off topic*:
why does
options("scipen" = 2^31-13); print(1236887146615);
produce different output [1] from
options("scipen" = 2^31-12); print(1236887146615);
and why does the rather intuitive approach suggested by one of my
colleagues,
options("scipen" = +Inf); print(1236887146615);
produce warnings (and why does warnings() then produce even more
warnings, ad infinitum)? ]
Hope this helps,
Allan
[1] at least under trunk and also 2.11.1
> sessionInfo()
R version 2.12.0 Under development (unstable) (2010-07-28 r52631)
Platform: x86_64-unknown-linux-gnu (64-bit)
locale:
[1] LC_CTYPE=en_GB.UTF-8 LC_NUMERIC=C
[3] LC_TIME=en_GB.UTF-8 LC_COLLATE=en_GB.UTF-8
[5] LC_MONETARY=C LC_MESSAGES=en_GB.UTF-8
[7] LC_PAPER=en_GB.UTF-8 LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_GB.UTF-8 LC_IDENTIFICATION=C
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] ctv_0.6-0
loaded via a namespace (and not attached):
[1] tools_2.12.0
More information about the R-help
mailing list