Seems like this should be easier, but if you create a new RStudio project with the "version control" option, the project created is just a project, not a package. Perhaps there is a simple way in RStudio to create a package from a project, but I can't find it.
So, we can create a Package, and then add version control. This assumes you have followed all of the installation instructions in Hadley Wickam's e-book R packages.
So, in RStudio, from the project drop down in the upper right corner, choose "new project," "new directory," "R Package," and then enter the relevant information. Be sure to click the "create a git repository" checkbox before finalizing the Package!! If the "create a git repository" checkbox is not present, git it probably not installed on your computer. See Hadley's e-book for that. .
IMPORTANT: You may have to enter the location of the Git.exe file (in the \bin folder of the Git installation) in R Studio (Tools->Global Options->Git/SVN) and maybe even restart R Studio before Git will play nicely with R Studio.
Once R Studio is running with Git (you can tell this is working if there is a "Git" tab in the upper right pane of R Studio when you have your newly created Package open), choose "Tools->Shell" and be sure the command prompt is displaying your Package root directory. From here, follow these lovely instructions from our friends at GitHub on how to push the new Package up to the remote repository on the GitHub website.
Once you have pushed your package to GitHub, close R, back up your package by renaming the package directory to <packagename>.bak (e.g. if your package is called "mypackage", then find the R studio directory called "mypackage" -- which should include subdirectories including .git, .Rproj.user, man, and R -- and rename the directory "mypackage.bak"). Then follow the instructions for "Pulling an R package from GitHub." This will recreate the <packagename> (e.g., "mypackage") directory from the information you pushed to GitHub, which allows you to test that all of the package information was pushed to GitHub correctly. Once you have worked with the new <packagename> directory for a few days are your are sure all is well, you can delete the .bak backup directory.
So, we can create a Package, and then add version control. This assumes you have followed all of the installation instructions in Hadley Wickam's e-book R packages.
So, in RStudio, from the project drop down in the upper right corner, choose "new project," "new directory," "R Package," and then enter the relevant information. Be sure to click the "create a git repository" checkbox before finalizing the Package!! If the "create a git repository" checkbox is not present, git it probably not installed on your computer. See Hadley's e-book for that. .
IMPORTANT: You may have to enter the location of the Git.exe file (in the \bin folder of the Git installation) in R Studio (Tools->Global Options->Git/SVN) and maybe even restart R Studio before Git will play nicely with R Studio.
Once R Studio is running with Git (you can tell this is working if there is a "Git" tab in the upper right pane of R Studio when you have your newly created Package open), choose "Tools->Shell" and be sure the command prompt is displaying your Package root directory. From here, follow these lovely instructions from our friends at GitHub on how to push the new Package up to the remote repository on the GitHub website.
Once you have pushed your package to GitHub, close R, back up your package by renaming the package directory to <packagename>.bak (e.g. if your package is called "mypackage", then find the R studio directory called "mypackage" -- which should include subdirectories including .git, .Rproj.user, man, and R -- and rename the directory "mypackage.bak"). Then follow the instructions for "Pulling an R package from GitHub." This will recreate the <packagename> (e.g., "mypackage") directory from the information you pushed to GitHub, which allows you to test that all of the package information was pushed to GitHub correctly. Once you have worked with the new <packagename> directory for a few days are your are sure all is well, you can delete the .bak backup directory.