1
我已經在R包中編寫了S4類。我用roxygen2
的文檔:S4構造函數超載的類在roxygen2文檔中有重複
#' A timeframe class represents a start date, end date and frequency
#'
#' @slot start_date First date in the timespan
#' @slot end_date Last date in the timespan
#' @slot frequency 'D', 'W' or 'M' for daily, weekly or monthly
#' @export
#' @exportClass timeframe
timeframe <- setClass("timeframe", slots = c(start_date = "Date", end_date = "Date", frequency = "character"),
prototype = list(
start_date = lubridate::as_date(lubridate::today() - 367),
end_date = lubridate::as_date(lubridate::today() - 1),
frequency = "D"
),
validity = function(object) {
# ...some validation stuff...
}
)
後來,我寫的過載功能,使一個更好的用戶界面:
#' @param start_date First date in the timespan
#' @param end_date Last date in the timespan
#' @param frequency 'D', 'W' or 'M' for daily, weekly or monthly
#' @export
timeframe <- function(start_date, end_date, frequency = "D") {
# ...some validation steps, such as setting default dates if they're missing...
return_object = new("timeframe", start_date = start_date, end_date = end_date, frequency = frequency)
return(return_object)
}
我想我需要記錄兩件事讓智能感知自動完成將工作不管用戶創建timeframe
對象的方式。問題是,文件雙打一些東西: 我做錯了什麼?我如何解決它?
我用'@ param'行替換了'@ slot'行,重載函數上面的註釋現在只是一行'''@ export'。這似乎工作。謝謝。 – lebelinoz