strptime函数的日期时间返回NA

时间:2018-10-22 21:56:28

标签: r

我需要将以下数据转换为日期时间变量:

fecha        tiempo      colcap
02/08/2010  09:00:01    1562.926
02/08/2010  09:00:02    1563.24

我以cbind(fecha,tiempo)创建了“ HMS”,然后我使用strptime函数将HMS转换为“%d /%m /%Y%H:%M:%s”格式,但HMS已转换在北美。

代码:

test=read.csv2('test.csv',sep= ',',header = TRUE)
test$colcap <-as.numeric(as.character(test[,3]))
# Convertir fecha a objeto date time
test[,'fecha'] = as.data.frame(strptime(test[,'fecha'],format="%d/%m/%Y"))
test=cbind(test,apply(test[,1:2,drop=FALSE],1,paste,collapse=" "))
names(test)[4]="HMS"
test[,'HMS']=as.character(test[,'HMS'])

test[,"HMS"]=as.data.frame(strptime(test[,4],format="%d/%m/%Y %H:%M:%s"))

请帮助我。

0 个答案:

没有答案
相关问题