gpt4 book ai didi

r - 警告 : “Variables with usage in documentation object ‘FANG’ but not in code:”

转载 作者:行者123 更新时间:2023-12-04 14:08:21 26 4
gpt4 key购买 nike

在 R-devel(当时 >3.6.1)上,运行 R CMD Check 时,我的包中弹出一个新警告,如下所示:

“Variables with usage in documentation object ‘FANG’ but not in code:”
'FANG'

FANG 是我包含在包中的数据集。

您可以在以下位置查看确切的错误:
https://travis-ci.org/business-science/tibbletime/jobs/568639099#L3163

您可以在以下位置查看此包的卡住状态:
https://github.com/business-science/tibbletime/blob/305e80ee3f6eecd728eb06937650dae03c94320c/R/data.R#L18

下面,我回答了我自己关于此错误的含义以及发生原因的问题。

最佳答案

这是 R-devel 中引入的一项新检查:
https://github.com/wch/r-source/commit/c9adb21c2e37cbc6dccd4c1eceec1873c10e3d9e#diff-4882a8c8e173bda109ed98da485e1428

虽然错误消息令人困惑,但对我来说解决方法是设置 LazyData: true在我的描述文件中。

问题是在我的 data.R 中文件,我使用 roxygen2 生成 Rd 文件。 data.R文件看起来像:

#' Stock prices for Facebook, Amazon, Netflix and Google from 2013-2016
#'
#' A dataset containing the date, open, high, low, close, volume, and adjusted
#' stock prices for Facebook, Amazon, Netflix and Google from 2013-2016.
#'
#' @format A tibble with 4,032 rows and 8 variables:
#' \describe{
#' \item{symbol}{stock ticker symbol}
#' \item{date}{trade date}
#' \item{open}{stock price at the open of trading, in USD}
#' \item{high}{stock price at the highest point during trading, in USD}
#' \item{low}{stock price at the lowest point during trading, in USD}
#' \item{close}{stock price at the close of trading, in USD}
#' \item{volume}{number of shares traded}
#' \item{adjusted}{stock price at the close of trading adjusted for stock splits, in USD}
#' }
#' @source \url{http://www.investopedia.com/terms/f/fang-stocks-fb-amzn.asp}
"FANG"

生成的 Rd 看起来像:
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/data.R
\docType{data}
\name{FANG}
\alias{FANG}
\title{Stock prices for Facebook, Amazon, Netflix and Google from 2013-2016}
\format{A tibble with 4,032 rows and 8 variables:
\describe{
\item{symbol}{stock ticker symbol}
\item{date}{trade date}
\item{open}{stock price at the open of trading, in USD}
\item{high}{stock price at the highest point during trading, in USD}
\item{low}{stock price at the lowest point during trading, in USD}
\item{close}{stock price at the close of trading, in USD}
\item{volume}{number of shares traded}
\item{adjusted}{stock price at the close of trading adjusted for stock splits, in USD}
}}
\source{
\url{http://www.investopedia.com/terms/f/fang-stocks-fb-amzn.asp}
}
\usage{
FANG
}
\description{
A dataset containing the date, open, high, low, close, volume, and adjusted
stock prices for Facebook, Amazon, Netflix and Google from 2013-2016.
}
\keyword{datasets}

问题在 \usage{}部分。我有 LazyData: false隐含地,这意味着 \usage{FANG}不正确,应该是 \usage{data(FANG)} .我的 data.R 中没有什么可以改变的文件来生成这个,因为 roxygen2 基本上假设你有 LazyData: true当它生成数据 Rd 文件时。

所以,这是 R CMD Check 发现的一个真正的错误,但该消息有点令人困惑。幸运的是,修复相当简单,而且是非侵入性的。

关于r - 警告 : “Variables with usage in documentation object ‘FANG’ but not in code:”,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57396392/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com