简体   繁体   English

如何从已克隆的 GitHub 编辑 R package?

[英]How do I edit an R package from GitHub that has already been cloned?

I have an R package, created by someone else that I have been made a collaborator on, that I want to work on and develop.我有一个 R package,由其他人创建,我已经成为合作者,我想继续工作和开发。 I've already cloned the repository to my local computer through the Create Project > Clone from GitHub route in RStudio, and since then I've been editing the scripts, but not working with it as a package.我已经通过 RStudio 中的 Create Project > Clone from GitHub 路由将存储库克隆到我的本地计算机,从那时起我一直在编辑脚本,但没有将其作为 ZEFE90A8E604A7C640E88D03A7D 使用。 As in, I had been adding functions and working on a Shiny interface, but not following any R package development rules (loading packages directly into the.R files, not updating the NAMESPACE, using roxygen2 conventions, etc.). As in, I had been adding functions and working on a Shiny interface, but not following any R package development rules (loading packages directly into the.R files, not updating the NAMESPACE, using roxygen2 conventions, etc.).

Everything I've read mentions devtools::install_github, but I don't want to install and use it, I want to edit it like I've been doing.我读过的所有内容都提到了 devtools::install_github,但我不想安装和使用它,我想像我一直在做的那样编辑它。 I also want it to still be connected to Git (so I can continue to commit and pull from the remote server, once my collaborators make edits).我还希望它仍然连接到 Git(这样我就可以在我的合作者进行编辑后继续从远程服务器提交和拉取)。 I've tried devtools::load_all() and devtools::document(), but it gives me this warning:我试过 devtools::load_all() 和 devtools::document(),但它给了我这个警告:

Error in FUN(X[[i]], ...) : 
  bad restore file magic number (file may be corrupted) -- no data loaded
In addition: Warning messages:
1: In readChar(con, 5L, useBytes = TRUE) :
  truncating string with embedded nuls
2: file ‘file_example.rda’ has magic number 'X'
  Use of save versions prior to 2 is deprecated 

Do I need to delete my local copy and do something different to work with it as a package so that the functionality of roxygen2 and the NAMESPACE documentation will work correctly?我是否需要删除我的本地副本并做一些不同的事情来将其作为 package 使用,以便 roxygen2 的功能和 NAMESPACE 文档能够正常工作? Or is there an obvious reason for this error/something I'm missing about how to work with it as a package, how it is currently?或者这个错误是否有明显的原因/我缺少关于如何将它作为 package 使用的东西,目前情况如何?

Thanks!谢谢!

It looks like file_example.rda is corrupt看起来file_example.rda已损坏

Can you just load it in R and check what it contains?您可以将其加载到 R 并检查其中包含的内容吗?

You could try:你可以试试:

tools::resaveRdaFiles( 'file_example.rda', compress='xz' )

And see if that saves it in a way that is acceptable?看看这是否以可接受的方式保存它?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM