Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/67.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
将MySQL时间戳转换为R-date格式_Mysql_R_Ggplot2 - Fatal编程技术网

将MySQL时间戳转换为R-date格式

将MySQL时间戳转换为R-date格式,mysql,r,ggplot2,Mysql,R,Ggplot2,我有一个MySQL表,其中新条目有如下时间戳: `timestamp` timestamp NULL default CURRENT_TIMESTAMP, 2014-01-01 01:01:01 看起来是这样的: `timestamp` timestamp NULL default CURRENT_TIMESTAMP, 2014-01-01 01:01:01 我希望能够在ggplot2散点图中绘制这些时间戳,使用: [...] if(myxaxis == "timestamp") {

我有一个MySQL表,其中新条目有如下时间戳:

`timestamp` timestamp NULL default CURRENT_TIMESTAMP,
2014-01-01 01:01:01
看起来是这样的:

`timestamp` timestamp NULL default CURRENT_TIMESTAMP,
2014-01-01 01:01:01
我希望能够在ggplot2散点图中绘制这些时间戳,使用:

[...]
if(myxaxis == "timestamp") {
   p = p + scale_x_datetime(as.POSIXct("xvalue"))                                                                                                                      
 }
 print(p)
[...]
我得到一个错误:

Error: character string is not in a standard unambiguous format

如何将时间戳转换为ggplot2的scale_x_date的正确日期格式?

目前,as.POSIX函数似乎正在尝试计算实际字符串xvalue的日期和时间。如果日期/时间字符串存储在名为xvalue的变量中,请尝试删除双引号:

p = p + scale_x_datetime(as.POSIXct(xvalue))  

这不就是UNIX_时间戳除以86400吗?你能告诉我们mysql中的实际日期字符串吗?