Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/66.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/mercurial/2.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
R 输出特定日期_R_Xts - Fatal编程技术网

R 输出特定日期

R 输出特定日期,r,xts,R,Xts,我在使用xts时遇到困难。当我使用以下命令(或更改日期)时,要么只输出一个标题,要么输出所有值 我正在使用read.csv Date Time ws wd 1 10/04/14 00:00:00 1.88 118 2 10/04/14 00:04:30 1.91 118 3 10/04/14 00:09:00 1.90 114 然后,我使用以下命令将日期和时间列转换为日期和时间 datax1 <- xts(data1[-c(1,2)], as.POSIXlt(paste(a

我在使用
xts
时遇到困难。当我使用以下命令(或更改日期)时,要么只输出一个标题,要么输出所有值

我正在使用
read.csv

Date     Time   ws  wd
1 10/04/14 00:00:00 1.88 118
2 10/04/14 00:04:30 1.91 118
3 10/04/14 00:09:00 1.90 114
然后,我使用以下命令将日期和时间列转换为日期和时间

datax1 <- xts(data1[-c(1,2)],
as.POSIXlt(paste(as.Date(data1$Date, format="%d-%m-%y"),
data1$Time), tz=""))

datax1似乎错误是传递给
as.Date
的格式字符串。它指定
-
字符,但您在实际输入中使用的是
/
字符

执行所需操作的最简单方法是对列本身使用
粘贴
,然后使用适当的格式字符串传递到
as.POSIXlt

with(data1, as.POSIXlt(paste(Date, Time), format="%d/%m/%y %H:%M:%S"))
## [1] "2014-04-10 00:00:00" "2014-04-10 00:04:30" "2014-04-10 00:09:00"
with(data1, as.POSIXlt(paste(Date, Time), format="%d/%m/%y %H:%M:%S"))
## [1] "2014-04-10 00:00:00" "2014-04-10 00:04:30" "2014-04-10 00:09:00"