在R包中显示编号列表

时间:2018-02-10 16:27:59

标签: r r-package roxygen2

我无法在R包帮助中显示编号列表。

这就是我在roxygen中所拥有的东西:

#' @return
#' Bunch of text
#' Bunch of text: 
#'  \enumerate {
#'    \item a
#'    \item b
#'    \item c
#' }

这显示没有数字。保存文件后,我点击Build & Reload in RStudio,然后点击devtools::document,然后点击devtools::load_all。当我在包上运行帮助时,我在控制台中收到以下消息:

Using development documentation for function name

1 个答案:

答案 0 :(得分:10)

一个简单的空格导致丢失的数字:只需删除enumerate和第一个{之后的空格。

第二个问题是缺少标题文档(导致文档构建失败,但我想这不是你的问题,因为你认识到缺少的数字,所以构建必须成功)。

这将有效:

#' My title...
#' @return
#' Bunch of text
#' Bunch of text:
#'  \enumerate{
#'    \item a
#'    \item{b}
#'    \item{c}
#' }
hello1 <- function() {
  print("Hello, world!")
}

?hello1然后显示:

enter image description here

PS:您可以在构建日志中识别RStudio中的这种问题:

  

警告:hello1.Rd:12:意外的文字'',期待'{'

修改1:

生成的Rd文件的名称和此文件中的行号在冒号后面的警告中显示(此处:12)。

您可以在程序包的man文件夹中找到生成的Rd文件。

只需打开它并查找行号以检查问题:

% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/hello1.R
\name{hello1}
\alias{hello1}
\title{My title...}
\usage{
hello1()
}
\value{
Bunch of text
Bunch of text:
 \enumerate {         % <- this is line number 12 !!!!
   \item a
   \item{b}
   \item{c}
}
}
\description{
My title...
}