如何将日期和时间合并到一个datetime列中 [英] How to merge date and time into one datetime column
本文介绍了如何将日期和时间合并到一个datetime列中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个最近制作的data.frame,它具有三列,即Date,Time和Data。我希望将日期和时间变量合并为一个Date.Time变量。
I have a recently made data.frame that has three columns, Date, Time, and Data. I'm looking to combine the date and the time variables into one Date.Time variable.
我的data.frame称为 data_dataframe
,看起来像这样:
My data.frame is called, data_dataframe
and looks like this:
Date Time Data
1/26/94 13:00 8.4
我尝试过:
as.POSIXct(paste(data_dataframe$Date, data_dataframe$Time), format="%d/%m/%Y %H:%M:%S")
但这不起作用。读书似乎并没有解决我的问题。有提示吗?
but this didn't work. Reading around didn't seem to help my problem. Any tips?
推荐答案
您可以尝试使用此方法,以创建带有 New_DateTime的新列
you could try this which will create a new column with 'New_DateTime'
data_dataframe$New_DateTime <- paste(data_dataframe$Date, data_dataframe$Time)
这篇关于如何将日期和时间合并到一个datetime列中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文