从星星对象中删除 NA - 关于小插图的问题

问题描述

我正在尝试学习 R 的星星包,并且有一个关于小插图中的代码的问题。我的问题的数据可在星星包中找到。代码如下:

library(stars)

prec_file = system.file("nc/test_stageiv_xyt.nc",package = "stars")
prec = read_ncdf(prec_file,curvilinear = c("lon","lat"))
## no 'var' specified,using Total_precipitation_surface_1_Hour_Accumulation
## other available variables:
##  time_bounds,lon,lat,time
## No projection information found in nc file. 
##  Coordinate variable units found to be degrees,##  assuming wgs84 Lat/Lon.
## Warning in .get_nc_dimensions(dimensions,coord_var = all_coord_var,coords =
## coords,: bounds for time seem to be reversed; reverting them
##plot(prec) ## gives error about unique breaks
## remove NAs,zeros,and give a large number
## of breaks (used for validating in detail)
qu_0_omit = function(x,...,n = 22) {
  if (inherits(x,"units"))
    x = units::drop_units(na.omit(x))
  c(0,quantile(x[x > 0],seq(0,1,length.out = n)))
}

这里让我感到困惑。有人可以向我解释为什么 NA 会被删除吗?我问是因为我正在使用 NetCDF,我相信我需要消除 NA,但我没有收到有关中断的错误。我尝试只使用与 NA 相关的部分功能,如下所示:

remove_NAs = function(x) {
  if (inherits(x,"units"))
    x = units::drop_units(na.omit(x))
}

后执行以下操作:remove_NAs(mydata) 但这不起作用。我没有收到错误,但 NA 仍然出现在我的数据集中。我实际上也没有在示例数据集中看到任何 NA,所以我什至不确定要删除什么。有人可以解释这里发生了什么吗?非常感谢。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...