我正在使用sqldf
连接几个表,但我无法在列上保留times
包含包的类集chron
。我使用了函数的method="name__class"
参数,sqldf
并用类适当地命名了我的列,但我的times
变量在选择后没有保留sqldf
。
是否可以选择一个times
类列并保留该类,或者我必须在 SQL 选择之后重置该类(这并不理想)。我已经包含了一个玩具示例,它显示了如何sqldf
保留 Date 类,而不是times
类:
library(chron)
mytime = data.frame(x=times(c("11:45:00", "12:15:00")))
mytime$y = as.Date(c("2019-09-01", "2019-09-11"))
mytime
x y
1 11:45:00 2019-09-01
2 12:15:00 2019-09-11
class(mytime$x)
[1] "times"
class(mytime$y)
[1] "Date"
sqldf('select x as x__times, y as y__Date from mytime', method = "name__class")
x__times y
1 0.4895833 2019-09-01
2 0.5104167 2019-09-11
在此先感谢您的帮助。