Questions tagged [r-package]

This tag should be used for questions regarding the development of R packages. Do not use this tag to ask questions about the use of R packages. Many common R packages have their own tags for that purpose.

This tag should be used for questions regarding the development of R packages. Do not use this tag to ask questions about the use of R packages. Many common R packages have their own tags for that purpose.

The R Core Team defines a package in the Manual on Writing R Extensions:

A package is a directory of files which extend R, a source package (the master files of a package), or a tarball containing the files of a source package, or an installed package, the result of running R CMD INSTALL on a source package. On some platforms (notably OS X and Windows) there are also binary packages, a zip file or tarball containing the files of an installed package which can be unpacked rather than installing from sources.

1279 questions
13
votes
2 answers

dplyr 0.7.0 tidyeval in packages

Preamble I commonly use dplyr in my packages. Prior to 0.7.0, I was using the underscored versions of dplyr verbs to avoid NOTEs during R CMD CHECK. For example, the code: x <- tibble::tibble(v = 1:3, w = 2) y <- dplyr::filter(x, v > w) would have…
user3646834
13
votes
2 answers

When does a package need to use ::: for its own objects

Consider this R package with two functions, one exported and the other internal hello.R #' @export hello <- function() { internalFunctions:::hello_internal() } hello_internal.R hello_internal <- function(x){ print("hello…
SymbolixAU
  • 25,502
  • 4
  • 67
  • 139
13
votes
1 answer

Package Relative Paths in R

I've written a few functions for a package that use relative paths like: "./data/foobar.rds" Here's an example function: foo <- function(x) { x <- readRDS("./data/bar.rds") return(x) } Now, if I were to be working in the development path of the…
Brandon Bertelsen
  • 43,807
  • 34
  • 160
  • 255
12
votes
1 answer

"Back engineering" an R package from compiled binary version

I work for an organization with a number of internal R packages, all written many years ago. These are stored as .zip archives built on Windows under R 3.x. They cannot be loaded on Linux or macOS or under R 4.y without being rebuilt. Unfortunately,…
hokeybot
  • 195
  • 5
12
votes
1 answer

CRAN submission - R CMD Check warning - compilation flags used

I am trying to submit my first package to CRAN and on my machine, I am getting the following warning on running R CMD check (via RStudio) checking compilation flags used ... WARNING Compilation used the following non-portable flag(s): …
Satya
  • 1,708
  • 1
  • 15
  • 39
12
votes
1 answer

Displaying numbered list in R package

I'm having trouble getting a numbered list to display in R package help. Here's what I have in roxygen: #' @return #' Bunch of text #' Bunch of text: #' \enumerate { #' \item a #' \item b #' \item c #' } This is displaying without…
matsuo_basho
  • 2,833
  • 8
  • 26
  • 47
12
votes
2 answers

reg.finalizer() in an R package does not execute at the end of an R session

From the documentation ?reg.finalizer in R: Inter alia, it provides a way to program code to be run at the end of an R session without manipulating .Last. For use in a package, it is often a good idea to set a finalizer on an object in the…
Yihui Xie
  • 28,913
  • 23
  • 193
  • 419
12
votes
1 answer

R CMD Check: Skip 'checking re-building of vignette outputs'

I build my R package using --no-build-vignettes because the vignette takes very long to run. Hence, I also want to avoid that "R CMD Check " checks for the vignette re-build. I tried to use --no-check-vignettes. However this gets ignored (not sure…
pat-s
  • 5,992
  • 1
  • 32
  • 60
12
votes
1 answer

How to add external data file into developing R package?

I am building my R packages in Rstudio, I ran into some unexpected problem when I tired to create package' vignette. when I hit build/load panel in Rstudio, I got vignette error, while package's documentation was created. To possibly solve vignette…
Hamilton
  • 620
  • 2
  • 14
  • 32
12
votes
1 answer

Possible to use newline inside roxygen2 code block?

I'm wondering if it's possible to insert newlines inside code blocks in roxygen2 when documenting a function? If I have something inside \code{}, roxygen2 collapses all newlines into single spaces by default. I tried inserting \cr inside to enforce…
DeanAttali
  • 25,268
  • 10
  • 92
  • 118
12
votes
1 answer

Including Command Line Scripts with an R Package

I am interested in providing a command line interface to an R package called Slidify that I am authoring. It uses Rscript and I think that would make it cross-platform. The scripts are stored in the subdirectory inst/slidify. In order to use the…
Ramnath
  • 54,439
  • 16
  • 125
  • 152
12
votes
1 answer

R package dependencies

i'm trying to build a R package, but it seems that there are some problems with the package dependencies. If I run the code in R, I need the packages "rgdal" and "rgeos", so for creatng the package out of it, I: Added the line "import(rgdal,…
tobias b.
  • 135
  • 1
  • 6
11
votes
1 answer

import all the functions of a package except one when building a package

I'm building an R package (mypackage) that imports data.table and another package (let's call it myotherpackage). Imports: data.table, myotherpackage is in the DESCRIPTION file of mypackage. myotherpackage imports dplyr, which has several functions…
Julien Massardier
  • 1,326
  • 1
  • 11
  • 29
11
votes
1 answer

load/remove user-defined unit on package load/unload: best practise?

In a package I am developing I need to define a new unit: flight level (FL) equivalent to 100 ft. The units package provides the following possibility: units::install_conversion_constant("FL", "ft", 100) In order to make package test…
espinielli
  • 666
  • 1
  • 6
  • 19
11
votes
4 answers

Installing package fails when building vignettes ((..)/doc/index.html is missing)

I'm creating an R package with a vignette. However, when I try to install the package by using devtools::install(build_vignettes = TRUE) an error occurs since it cannot find the file index.html in the doc folder. I thought this file would be…
Linda Nab
  • 111
  • 4
1 2
3
85 86