【发布时间】:2019-10-06 15:11:14
【问题描述】:
我在脚本中有一些函数,我想使用#roxygen2 记录这些函数,但在线资源已经看到指向在包中记录函数。我不想创建一个包,而只是记录我的自定义函数。任何资源都会有所帮助。
我已经使用#roxygen2 语法编写了有关该函数的一些详细信息并尝试记录它,但它返回“错误:package.dir 必须包含说明文件”,并且,
“您是否在不是包根目录的目录中调用了roxygenize()?”
这里是#roxygen2 笔记
#'@title get_weather.
#'@description The function takes arguments of directory, country, station and year.
#'@param directory The directory where the weather data is stored relative to the working.
#'@param country The country where the data was recorded
#'@param station The weather station number.
#'@param year The year in which the data was recorded.
#'@return A data frame called WDATA. it contains data on vapour pressure(VP), wind speed (WN), precipitation (RAIN), daily total radiation (DTR) and daily average temperature (DAVTMP).
这是我要记录的函数
get_weather <-
function(directory="..\\weather\\",country="NLD",station="1",year="954"){
weather <-
matrix(data=as.numeric(unlist(scan(paste(directory,country,
station,".",year,sep=""), what=list("","","","","","","","",""),
comment.char='*',fill=TRUE,quiet=TRUE))),ncol=9)
RDD = as.vector(weather[-1,4])
TMMN = as.vector(weather[-1,5])
TMMX = as.vector(weather[-1,6])
WDATA <- data.frame(
VP = as.vector(weather[-1,7]),
WN = as.vector(weather[-1,8]),
RAIN = as.vector(weather[-1,9]),
DTR = RDD / 1e+03,
DAVTMP = 0.5 * (TMMN + TMMX)
)
}
【问题讨论】: