数据包R文档

时间:2019-05-24 10:21:55

标签: r devtools r-package roxygen2

我正在创建一个程序包,并且为文档生成的Rd文件的自动生成与Roxygen2的功能配合正常(这是我的R文件的示例,其中使用roxygen2 :: roxygenise()提供了一个好的Rd文件:

#' Total flows of a DF
#'
#' This function allows you to store the totals of origins, destinations and intrenals flows for each city in a dataframe,
#' from a long format matrix of flows.
#'
#' @param tabflows A data.frame of flows between origins and destinations (long format matrix containing, at least, origins, destinations, flows)
#' @param idori identifiant ori
#' @param iddes identifiant des
#' @param idflow identifiant flux
#' @return A data.frame of totals origins, destinations and internals flows for each city
#'
#' @examples
#' data(tabflows)
#'
#' popTab <- pop_tab(tabflows = tabflows, idori = "ORI", iddes = "DES", idflow = "FLOW")
#'
#' popTab[10:10,]
#'
#' @export
#' @importFrom stats aggregate

pop_tab <- function(tabflows, idori, iddes, idflow){
  tabflowIntra <- tabflows[tabflows[idori] == tabflows[iddes], ]
  tabflowIntra <- aggregate(x = tabflowIntra[[idflow]], by = list(tabflowIntra[[idori]],tabflowIntra[[iddes]]), FUN = sum)
  colnames(tabflowIntra) <- c("ORI", "DES","TOTINTRA")
  tabflowOri <- tabflows[tabflows[idori] != tabflows[iddes], ]
  tabflowOri <- aggregate(x = tabflowOri[[idflow]], by = list(tabflowOri[[idori]]), FUN = sum)
  colnames(tabflowOri) <- c("ORI","TOTORI")
  tabflowDes <- tabflows[tabflows[idori] != tabflows[iddes], ]
  tabflowDes <- aggregate(x = tabflowDes[[idflow]], by = list(tabflowDes[[iddes]]), FUN = sum)
  colnames(tabflowDes) <- c("DES","TOTDES")
  poptab <- merge(x = tabflowIntra, y = tabflowOri, by.x = idori, by.y =idori)
  poptab <- merge(x = poptab, y = tabflowDes, by.x = idori, by.y =iddes)
  poptab[[iddes]] <- NULL
  colnames(poptab) <- c("idflow", "TOTINTRA","TOTORI", "TOTDES")
  return(poptab)
}

但是,当我尝试roxygenise()这个与数据文档有关的下一个R文件时,在man目录中没有生成Rd文件。我当然可以自己写Rd文件,但是我想知道这里是什么问题...

#' @title Commuters
#' @name tabflows
#' @description Data on commuters between Urban Areas in Paris region in 2014.
#' Fields: \cr
#' \itemize{
#' \item{ORI: Code of the urban area of residence}
#' \item{DES: Code of the urban area of work}
#' \item{MODE: Transport mode used by the workers}
#' \item{FLOW: Number of commuters between i and j}
#' \item{DIST: distance between the urban area of work and the urban area of residence}
#' \item{DISTTOT: total distance between the urban area of work and the urban area of residence}
#' \item{ORILIB: Name of the urban area of residence}
#' \item{DESLIB: Name of the urban area of work}
#' }
#' @docType data
#' @examples
#' ## tabflows
#' data(tabflows)

1 个答案:

答案 0 :(得分:2)

在最后一行之后写NULL

......
#' @examples
#' ## tabflows
#' data(tabflows)
NULL