Page MenuHomec4science

Rstudio integration with c4science
Updated 2,724 Days AgoPublic

We will explain here 2 use cases:

Both use cases need SSH keys to be already set up.

You use R or Rstudio but no projects, you are already versioning your work but no integration from within Rstudio.

While working on Rstudio on your files, associate your work with a project with the New Project dialog: File -> New project

and choose Existing directory

Choose the directory (if you launched Rstudio from it it should be already there) and Create project. This, in pracctice, will create an .Rproj file and modify your .gitignore (check it out with git diff .gitignore)

The system is smart enough to detect if you are using Git. On the bar, you should see a small "Git" icon.

From the Git icon, you can do all the common Git operations you would do on the command line.

Committing

If you choose Git -> commit..., you will be presented with the "Review Changes" panel, which is pretty straightforward. You tick the files you want to "Add", add a commit message and click commit. Once this is done, you can click on "Push".

Setting up from scratch

You first need to create a repository on C4science.

From within Rstudio, you create a new project with File -> New Project, choose New directory. You then have to pick the type of Project (standard, package, shiny). If you are familiar with R, you'll know what to choose. If you're not, choose Empty Project. Choose a directory name etc and tick the Create a git repository box.

What you have done here included a git init on the Rproject folder. You should now see a Git symbol on the toolbar.

You can now work on your files and commit, but you need to add an origin to be able to push to c4science: from Rstudio, lauch a shell via Tools -> Shell and type the following:

git config --global user.email "YOUR@EMAIL"
git config --global user.name "C4SCIENCE_USERNAME"
git remote add origin ssh://git@c4science.ch/diffusion/997/simplegitrepo.git
git push --set-upstream origin master

Change the email and the username to yours and ssh:// URL to whatever is your repo's URL. Now you can push your commits to C4science.

Clone a repository from c4science

In RStudio, click New project as normal. Choose Version Control. Then, pick Git or SVN. Then, enter the repo data. Rstudio will clone the project into the chosen directory and, if needed, create an .Rproj file. You're now good to go with Rstudio and c4science. You can use the Git menu and commit + push from within Rstudio.

Last Author
rezzonico
Last Edited
Oct 31 2016, 11:26

Event Timeline

rezzonico created this document.Oct 31 2016, 09:30
rezzonico edited the content of this document. (Show Details)
rezzonico edited the content of this document. (Show Details)
rezzonico edited the content of this document. (Show Details)Oct 31 2016, 10:25
rezzonico edited the content of this document. (Show Details)Oct 31 2016, 10:37
rezzonico changed the visibility from "rezzonico (Vittoria Rezzonico)" to "Public (No Login Required)".
rezzonico edited the content of this document. (Show Details)Oct 31 2016, 10:51
rezzonico edited the content of this document. (Show Details)Oct 31 2016, 11:12
rezzonico edited the content of this document. (Show Details)Oct 31 2016, 11:20
rezzonico edited the content of this document. (Show Details)Oct 31 2016, 11:25
rezzonico edited the content of this document. (Show Details)
aubort changed the edit policy from "c4science (Project)" to "Restricted Project (Project)".Dec 16 2016, 16:51