【问题标题】:Displaying numbered list in R package在 R 包中显示编号列表
【发布时间】:2018-07-21 05:37:33
【问题描述】:

我无法在 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

【问题讨论】:

  • 这是您完整的 roxygen 文档标题,因为没有标题我收到错误消息“缺少名称/标题。跳过”?

标签: r r-package roxygen2


【解决方案1】:

一个简单的空格导致缺少数字:只需删除enumerate 和第一个{ 之后的空格即可。

第二个问题是缺少标题文档(这会导致文档构建失败,但我想这不是您的问题,因为您识别出缺少的数字,因此构建必须成功)。

这将起作用:

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

?hello1 然后显示:

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

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

编辑 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...
}

【讨论】:

  • @R Yoda,有什么方法可以告诉文本中发生错误的位置吗?不是那里的行号...
  • @matsuo_basho:请参阅我在如何查找行号的答案中的编辑...
猜你喜欢
  • 2019-02-22
  • 2021-09-24
  • 2018-10-11
  • 1970-01-01
  • 1970-01-01
  • 2011-01-20
  • 2011-03-25
  • 2017-07-02
  • 1970-01-01
相关资源
最近更新 更多