I have some functions in a script that I would like to document those functions using #roxygen2, but the online resources have seen point towards documenting functions in a package. I do not want to create a package but just document my custom function as I go along. any resources would be of help.
I have written up some details about the function using #roxygen2 syntax and tried to document it but it returns an "Error: package.dir
must include a DESCRIPTION file" and,
"Did you call roxygenize()
in a directory that is not the package root?"
Here are #roxygen2 notes
#'@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).
Here is the function I want to document
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)
)
}