On R-devel (>3.6.1 at the time), a new warning has popped up in my package when running R CMD Check that looks like:
“Variables with usage in documentation object ‘FANG’ but not in code:”
'FANG'
FANG is a data set that I include in my package.
You can see the exact error at: https://travis-ci.org/business-science/tibbletime/jobs/568639099#L3163
You can see the frozen state of this package at: https://github.com/business-science/tibbletime/blob/305e80ee3f6eecd728eb06937650dae03c94320c/R/data.R#L18
Below, I answer my own question about what this error means, and why it occurred.
This is a new check introduced in R-devel here: https://github.com/wch/r-source/commit/c9adb21c2e37cbc6dccd4c1eceec1873c10e3d9e#diff-4882a8c8e173bda109ed98da485e1428
While the error message is confusing, the fix for me was to set LazyData: true
in my DESCRIPTION file.
The problem was that in my data.R
file, I use roxygen2 to generate the Rd file. The data.R
file looks like:
#' 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"
And the generated Rd looks like:
% 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}
The issue is in the \usage{}
section. I have LazyData: false
implicitly, which means that \usage{FANG}
is incorrect and should really be \usage{data(FANG)}
. There is nothing that I could have changed in my data.R
file to generate this, as roxygen2 essentially assumes you have LazyData: true
when it generates the data Rd file.
So, this is a true error picked up by R CMD Check, but the message is a bit confusing. Luckily, the fix is fairly easy, and non-invasive.
I had the same Warning: “Variables with usage in documentation object ‘ ’ but not in code”. I solved as suggested also by John M. You just need to add in the data documentation in data.R the following tag: @usage
So in the example above it should be #' @usage data(FANG)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With