简体   繁体   English

在github上开始新的R包开发

[英]Start new R package development on github

How do I create new repository on github using devtools in RStudio? 如何使用RStudio中的devtools在github上创建新的存储库? I've tried to: 我试过:

  1. Create empty repository on github named "MyNewRPackage" 在名为“MyNewRPackage”的github上创建空存储库
  2. Started new project in RStudio using ssh connection to my git repository 使用ssh连接到我的git存储库,在RStudio中启动了新项目
  3. Installed and loaded devtools 已安装和加载的devtools

Then I thought I will use create("MyNewRPackage") to initialize directory structure and README.md file. 然后我想我会使用create("MyNewRPackage")来初始化目录结构和README.md文件。 But the package skeleton is created as subfolder of my project and I have ~/MyNewRPackage/MyNewRPackage/R . 但是包骨架被创建为我项目的子文件夹,我有~/MyNewRPackage/MyNewRPackage/R But I need to create package skeleton in the root folder of my github repository. 但我需要在我的github存储库的根文件夹中创建包骨架。

What is the standard way to start new R package development on github using devtools and RStudio? 使用devtools和RStudio在github上开始新R包开发的标准方法是什么?

Hope this helps someone: 希望这有助于某人:

  1. Create empty repository on github (I will use name rpackage in this example) 在github上创建空存储库(在本例中我将使用名称rpackage
  2. Create package locally using devtools, create("rpackage") (this will create rpackage folder) 使用devtools在本地创建包, create("rpackage") (这将创建rpackage文件夹)
  3. Create new project in RStudio (Create project from: Existing directory) and choose rpackage directory 在RStudio中创建新项目(从:现有目录创建项目)并选择rpackage目录
  4. In RStudio go to Tools/Shell... and type git init 在RStudio中,转到Tools / Shell ...并键入git init
  5. Reopen the project (this will refresh the Git tab) 重新打开项目(这将刷新Git选项卡)
  6. Start Git/More/Shell and type 启动Git / More / Shell并键入

    git add *

    git commit -m "first commit"

    git remote add origin git@github.com:[username]/rpackage.git

    git push -u origin master

Then you can refresh repository on github . 然后你可以在github上刷新存储库。 Now you can close (or even delete) your local project and next time you can start a new project Project/New project/Version Control/Git 现在您可以关闭(甚至删除)本地项目,下次可以启动新项目Project / New project / Version Control / Git

You can specify the path to your github repository in create instead of the package name: 您可以在create指定github存储库的路径而不是包名:

create("/path/to/root/of/repository")

Then the normal git commands to add, commit and push to github: 然后是正常的git命令来添加,提交和推送到github:

git commit -a -m "initial commit" *
git push

Now there's setup() , which creates the skeleton inside an existing directory. 现在有setup() ,它现有目录中创建骨架。 Together with hub , this becomes: hub一起,这变为:

git init NewPackage
cd NewPackage
Rscript -e "devtools::setup()"
hub create
git add .
git commit -m "initial"
git push -u origin HEAD

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

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