roxygen2

Turning an R S3 ordinary function into a generic

只谈情不闲聊 提交于 2020-01-21 09:09:23
问题 FYI, looks like this question already has a LISP equivalent. Recently I wanted to create a dataframe extension to the R base function setdiff and thought a generic would be nice. The following works but is clunky: #' @export setdiff.default setdiff.default <- setdiff #' @export setdiff <- function(x, ...) { UseMethod("setdiff") } #' @export setdiff.data.frame <- function(A, B) { A[!duplicated(rbind(B, A))[nrow(B) + 1:nrow(A)], ] } When you load the package, the base function is masked. If I

R package building error

半世苍凉 提交于 2020-01-17 07:18:06
问题 I am trying to build an R package. I usually run the clean and rebuild command in Rstudio. I am now getting this error message: ==> devtools::document(roclets=c('rd', 'collate', 'namespace', 'vignette')) Updating ED2io documentation Loading ED2io Deleting grapes-equals-grapes.Rd Writing NAMESPACE Documentation completed ==> R CMD INSTALL --preclean --no-multiarch --with-keep.source EDio * installing to library ‘/opt/local/Library/Frameworks/R.framework/Versions/3.3/Resources/library’ *

How directly access S3 method in roxygen2 R package

落花浮王杯 提交于 2020-01-16 00:47:13
问题 I'm writing my first package with roxygen2 . The package implements a faster version of pcdtest() from plm package. Thus I call within my package: merr <- resid(mod) Package plm implements a S3 method for resid. It exports it in plm 's NAMESPACE this way: S3method("residuals", "panelmodel") S3method("residuals", "plm") To be able to use resid() , I import whole plm package via #' @import plm Is there any way to access the proper method directly via :: ? Or to import just the method? Or other

Can R help manuals have latex math in them?

ε祈祈猫儿з 提交于 2020-01-14 09:35:08
问题 I am working on an R package and I am using the package Roxygen2 to write the help manuals for my R functions. What I would like to know is if it is possible to use latex for math equations in the manual pages? For example, if I had a function called add2 that did the following: add2 = function(x,y){ z = x+y return(z) } And using Roxygen2 documentation I had the following: ##' @include add2.R {} ##' Compute the sum of x_1 and x_2 ##' ##' Computes the sum of x_1 and x_2 ##' ##' @param x_1

What is the correct way to import an S3 method without importing the whole package

雨燕双飞 提交于 2020-01-13 05:30:10
问题 I would like to use one function from a package called myPackage called as.data.frame.mywhateverS3class When I look at the package NAMESPACE it looks as follows: S3method(as.data.frame, mywhateverS3class) I would like to use this function inside another package. What I would normally do is specify this in roxygen2 as @import myPackage such that this generates import(myPackage) inside the other package. That works. But in this case I would like not to import the whole package but only the S3

Roxygen2: documenting S3 class used as S4 when overloading R base function (cor)

房东的猫 提交于 2020-01-11 11:15:09
问题 I have the following context: I do overload cor base function so that I have in my package .R file following statement: #'export setGeneric("cor") Now I want to create a specific function for my objects (class named stranger ) -- here for simplicity I just consider my object is a data.table with an additional column named .id . #' Correlation for stranger objects #' describeIn cor Correlation method for stranger objects. setMethod("cor",signature(x="stranger"),function(x, method = c("pearson"

“API rate limit exceeded” when trying to install local R package using devtools::install()

╄→гoц情女王★ 提交于 2020-01-10 05:03:25
问题 Package development beginner here! I'm trying to turn some code into a local R package for the very first time. I made a package using usethis::create_package() , added documentation using devtools::document() . Now, after playing around with it for a while, I ran into the following error when trying to install the newest version using devtools::install() : Error: HTTP error 403. API rate limit exceeded for [my IP]. (But here's the good news: Authenticated requests get a higher rate limit.

how to import with roxygen packages the pipe operator %>% from dplyr

我怕爱的太早我们不能终老 提交于 2020-01-04 05:53:42
问题 I want to build a package with some functions i wrote. Now my problem is, that i cannot use the pipe-operator %>% with dplyr. I create the package with roxygen2. If i write the dplyr-commands without %>%, everything works fine. inside the code: #' #' @import dplyr readr mailR writexl #' @importFrom dplyr %>% #' @name %>% #' #' @export #' I wrote: DESCRIPTION LazyData: true RoxygenNote: 6.0.1 Imports: dplyr roxygen2 generates: NAMESPACE ... importFrom(dplyr,"%>%") ... 回答1: Usually you would

Cannot install proprietary R library

不问归期 提交于 2020-01-03 04:46:29
问题 I have developed my own R library (called HAM) When I use the install() command from the library roxygen2 , the result looks as shown below: * installing *source* package 'HAM' ... ** R ** preparing package for lazy loading Warnung: package 'car' was built under R version 3.1.2 Warnung: package 'gmm' was built under R version 3.1.2 Warnung: package 'MASS' was built under R version 3.1.2 Warnung: package 'fAssets' was built under R version 3.1.2 Warnung: package 'timeDate' was built under R

Does roxygen2 automatically write NAMESPACE directives for “Imports:” packages?

江枫思渺然 提交于 2019-12-28 05:16:30
问题 tl;dr version of my question If I want to import packages, do I have to manually write import() directives into my NAMESPACE file? It seems like roxygen2 won't magically do that for me, even if I have them listed as "Imports:" in my description. Fuller Version This is a pretty dumb question, but I ask because the answer's not obvious to me. I use roxygen2 to handle my R package documentation. When I want to be sure a function is exported, I add an @export tag to its roxygen block. Subsequent