R package warrning description missing.

Building a very simple package on RStudio. I have a function that adds 2 to any given number. When I run "check package" from "build" tab, I am getting "argument items with no description" - what is missing?

Here is the content in the add_2.R file

# Add plus 2 to a number

#' Add
#'
#' @param x is number
#' @description x is an intiger
#' @return a number object
#' @export
#'
#' @examples
#' add_2(2)
add_2 <- function(x) { x + 2}

and the add_2.Rd

% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/add_2.R
\name{add_2}
\alias{add_2}
\title{Add}
\usage{
add_2(x)
}
\arguments{
\item{x}{is number}
}
\value{
a number object
}
\description{
x is an intiger
}
\examples{
add_2(2)
}

Here is what is rendered.
warrning

So, not sure this is the issue, but description should not be used for describing parameters, it is a short description of what the function does. So the .R file should rather be

#' @title Add plus 2 to a number (or #' Add plus 2 to a number, roxygen2 will guess it's the title)
#' 
#' @description More information about the function but still short.
#'
#' @param x A number (integer)
#' @return a number object
#' @export
#'
#' @examples
#' add_2(2)

Thanks for responding @maelle. Still get the warning after updating with your recommendation.

W  checking Rd contents ...
   Argument items with no description in Rd object 'add_2':
     ‘x’

and

0 errors ✓ | 1 warning x | 0 notes ✓
Error: R CMD check found WARNINGs
Execution halted

Exited with status 1.

Have you run document()? If I add the .R below in a package and then run document(), I get no R CMD check problems.

#' @title Add plus 2 to a number (or #' Add plus 2 to a number, roxygen2 will guess it's the title)
#'
#' @description More information about the function but still short.
#'
#' @param x A number (integer)
#' @return a number object
#' @export
#'
#' @examples
#' add_2(2)

add_2 <- function(x) {
  x + 2
}

2 Likes

I did run document(). The build-> check package keeps warning even with the change in the .R and running document(). I blew everything a way and started from scratch using your example. And the warning is gone. Thanks!

1 Like

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.