我正在尝试使用我自己制作的数据(使用 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)`
我尝试过的替代代码 - 读取由“ProcTraj”创建的 .Rdata 文件,详见“openair”手册的附录。在 Rstudio 中打开时,生成的“mydata”看起来相同(如下所示):
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)
这给出了错误:
“as.POSIXlt.character(mydata$date[1]) 中的错误:字符串不是标准的明确格式”
如果我添加:
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"))
我回到原来的错误。
我的数据:
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