我正在尝试使用我自己制作的数据(使用Hysplit和R / openair)在openair包(R)中制作回轨迹图。
我收到错误: " abs中的错误(mydata $ len):数学函数的非数字参数"。
我的代码(直接从csv文件读取轨迹数据):
# read in trajectory
mydata <- read.csv("c:/hysplit4/working/2014/2014rml.csv", header = TRUE,
stringsAsFactors = FALSE # I have tried with /without this line
)
# make sure dates are read correctly
mydata$date2 <- as.POSIXct(strptime(mydata$date2, format = "%Y-%m-%d %H:%M:%S"))
mydata$date <- as.POSIXct(strptime(mydata$date, format = "%Y-%m-%d %H:%M:%S"))
as.vector(as.matrix(mydata)) # I have tried with/ without this line
# plot trajectory for specific dates
library(openair)
library(mapdata)
trajPlot(mydata)`
我尝试过的替代代码 - 读取由&#39; ProcTraj&#39;创建的.Rdata文件。详见附录&lt; openair&#39;手册。当在Rstudio中打开时,产生的&#39; mydata&#39;看起来完全相同(如下所示):
mydata <- importTraj(site = "SuvaCity", year = 2014,
local = "C:/HYSPLIT/TrajProc/")
## at this point it prints the trajectory data on the screen and it looks fine
trajPlot(mydata)
这给出了错误:
&#34; as.POSIXlt.character(mydata $ date [1])出错: 字符串不是标准的明确格式&#34;
如果我加入:
mydata$date2 <- as.POSIXct(strptime(mydata$date2, format = "%Y-%m-%d %H:%M:%S"))
mydata$date <- as.POSIXct(strptime(mydata$date, format = "%Y-%m-%d %H:%M:%S"))
我回到原来的错误。
MYDATA:
receptor,year,month,day,hour,hour.inc,lat,lon,height,pressure,date2,date
1,2014,1,1,0,0,-18.134,178.424,18,1000.2,2014-01-01 00:00:00,2014-01-01 00:00:00
1,2013,12,31,23,-1,-18.089,178.532,30,998.6,2013-12-31 23:00:00,2014-01-01 00:00:00
1,2013,12,31,22,-2,-18.045,178.659,44.5,996.9,2013-12-31 22:00:00,2014-01-01 00:00:00
1,2013,12,31,21,-3,-18.002,178.806,61.5,995.3,2013-12-31 21:00:00,2014-01-01 00:00:00
1,2013,12,31,20,-4,-17.96,178.97,80.6,993.3,2013-12-31 20:00:00,2014-01-01 00:00:00
1,2013,12,31,19,-5,-17.92,179.151,100.5,990.4,2013-12-31 19:00:00,2014-01-01 00:00:00
1,2013,12,31,18,-6,-17.885,179.352,120.3,988,2013-12-31 18:00:00,2014-01-01 00:00:00
答案 0 :(得分:0)
您的.Rdata文件内容似乎没有问题。 mydata的日期格式应该不是问题。但是您可以尝试使用:
mydata$date=as.character(mydata$date)
mydata$date=as.POSIXct(mydata$date,tz="GMT")