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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/backbone.js/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
使用R在NC文件中传输到日期的小时数_R_Date - Fatal编程技术网

使用R在NC文件中传输到日期的小时数

使用R在NC文件中传输到日期的小时数,r,date,R,Date,我尝试使用ncdf软件包读取NC数据,其中读取时间维度 ti<-get.var.ncdf(nc,varid="time") nc$dim$time$unit "hours since 1-1-1 00:00:0.0" ti您可以执行以下操作: hours <- 17645592 # e.g. this is the number of hours from 01-01-01 to 2014-01-01 DATE <- as.POSIXct(x='01-01-01',tz='G

我尝试使用ncdf软件包读取NC数据,其中读取时间维度

ti<-get.var.ncdf(nc,varid="time")
nc$dim$time$unit
"hours since 1-1-1 00:00:0.0"
ti您可以执行以下操作:

hours <- 17645592 # e.g. this is the number of hours from 01-01-01 to 2014-01-01
DATE <- as.POSIXct(x='01-01-01',tz='GMT',format='%Y-%m-%d') + (hours*60*60)
# > DATE
#[1] "2014-01-01 GMT

hours如果你能知道1-1-1是什么时候开始的,那么就使用像as.POSIXct(“2001-01-01 00:00:00”,tz=“GMT”)+ti*3600这样的东西,没有人能猜到开始日期,尽管你经常会交叉检查以增加信心。