如何创建嵌套在git目录中的R包 [英] How to create an R package nested in git directory

查看:85
本文介绍了如何创建嵌套在git目录中的R包的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我曾经能够在github存储库中构建我的R包,但是devtools函数已被弃用,并被新的函数取代,这些新函数不再允许我这样做。

I used to be able to build my R packages within my github repo, but the devtools functions have been deprecated and replaced with new functions that won't allow me to do this anymore.

我以前在目录 / home / User /中使用 devtools :: setup('NewPackage',check = FALSE) NewPackage / ,以创建我的R包 / home / User / NewPackage / NewPackage

I was previously using devtools::setup('NewPackage', check=FALSE) in my directory /home/User/NewPackage/, to create my R package /home/User/NewPackage/NewPackage

新的替代方法出现以下错误

The new alternative gives the following error

usethis::create_package('NewPackage')
#New project 'NewPackage' is nested inside an existing project '/home/User/NewPackage/'
#This is rarely a good idea. Do you wish to create anyway?
#1: Negative
#2: I agree
#3: No way

我已经自动创建了包,但是这个新功能破坏了我所有包中的代码。

I had automated my package creation, but this new function breaks the code in all of my packages.

我将其发布为错误 https://github.com/r-lib/usethis/issues/553

但是我仍在寻找解决方法或以任何方式自动提交我同意

But I am still looking for a work around or any way to automatically submit I agree?

还有一些隐藏文件,例如 .Rd2pdf12059 ,在我的 / home / User / NewPackage / 目录中

There are also hidden files, such as .Rd2pdf12059, in my /home/User/NewPackage/ directory

在此问题得到解决之前,我只是复制了旧的devtools源代码,并删除了我不喜欢的代码。

Until this is fixed, I have just copied the old devtools source code and removed what I didn't like.

推荐答案

不是最干净的处理方式,但是您可以使用 testthat :: with_mock 欺骗 check_not_nested

Not the cleanest way of doing things, but you could use testthat::with_mock to trick check_not_nested:

testthat::with_mock(
  check_not_nested = function(path, name) return(),
  usethis::create_package('NewPackage2'),
  .env = "usethis"
)

这篇关于如何创建嵌套在git目录中的R包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆