Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/67.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/5/date/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
as.Date以明确的格式显示字符串,即使指定了strtime,也是如此_R_Date - Fatal编程技术网

as.Date以明确的格式显示字符串,即使指定了strtime,也是如此

as.Date以明确的格式显示字符串,即使指定了strtime,也是如此,r,date,R,Date,我有以下表格的日期栏: 20160812 20160813 基本上是YYYYMMDD 我使用strtime和as.date将其转换为日期 weather_dataset$DATE = as.Date(weather_dataset$DATE,"%Y%m%d") 但我明白了 Error in charToDate(x) : character string is not in a standard unambiguous format 嗯?我已经明确指定了要使用的格式,但出于某种原因,

我有以下表格的日期栏:

20160812
20160813
基本上是YYYYMMDD

我使用strtime和as.date将其转换为日期

weather_dataset$DATE = as.Date(weather_dataset$DATE,"%Y%m%d")
但我明白了

Error in charToDate(x) : 
  character string is not in a standard unambiguous format
嗯?我已经明确指定了要使用的格式,但出于某种原因,它仍然会给我带来这个错误。非常感谢您的帮助!:)


谢谢大家!

您的数据必须是字符。因此,请使用此解决方法:

weather_dataset$DATE <- as.Date(as.character(weather_dataset$DATE),"%Y%m%d")

weather\u dataset$DATE您太棒了,谢谢!一旦最小时间限制允许,将标记为正确
weather_dataset$DATE <- lubridate::ymd(weather_dataset$DATE)
library(anytime)

anydate(20160812)