【发布时间】:2017-09-18 23:01:43
【问题描述】:
我正在开发一个 R 包,可以在 DESCRIPTIONS 文件中找到它
Imports:
dplyr,
ggplot2,
ncdf4
我有一个使用第三个依赖项的示例函数
testFun <- function(file, lat, long){
ncfname <- file.path(file,fsep = .Platform$file.sep)
xfile <- nc_open(ncfname) #Opens the NetCDF file
lat <- ncvar_get(xfile, 'lat') #Extracts all latitudes
...Calculations
return(XYZ)
}
当我Build and Reload 包并运行该函数时,它是could not find function "nc_open"。
但是,当我用 ncdf4::nc_open 替换它时它可以工作
我应该在代码中使用的每个依赖项前加上 packagename:: 前缀吗?还是我错过了什么?
通常,我希望从DESCRIPTIONS 安装所有依赖项,并且它的功能可以使用,而无需每次都需要包前缀。
【问题讨论】: