【发布时间】:2018-06-09 01:07:37
【问题描述】:
我正在尝试使用 for 循环从 R 中的 SQL 查询中提取日期。目前我有:
StartDate<-"2017-07-01"
EndDate<- "2017-07-05"
dates<-seq(as.POSIXct(StartDate, format="%Y-%m-%d"), as.POSIXct(EndDate, format="%Y-%m-%d"), by='days')
for (f in dates){
.
. Code here that is inside for loop
.
}
我的问题是它不像 Dates 那样以日期格式出现。如何获得与 StartDate 和 EndDate 格式相同的 f?
【问题讨论】:
-
你就不能:
for (f in as.character(dates)) {}吗? -
在
for循环中尝试使用as.list包装日期