Tag Archives: Git

Things I Forget: Push/Pull Greyed out in RStudio?!?

So, on more than one occasion I have set up a repository locally, then on GitHub and pushed to that repo from the shell. This works great, but this would always result in the Push and Pull buttons in RStudio getting greyed out. I could push just fine from the shell, but not from the GUI. Not a big problem, but always kind of annoyed me.

Today I took a bit of time to search for a solution and found my answer pretty quickly over on RStudio support.  All I had to do was simply push from the shell with the -u flag. This flag added an upstream reference.

Prior to fixing it my config looked like:

user.name=Jeff Hollister

And after using git push -u origin master, my config had these two lines added at the bottom:


I restarted RStudio and can now push and pull from the GUI.  Yeah!

Lastly, this really isn’t something I have forgotten yet, I just looked it up. But, it does seem like something I would forget. I am just being proactive here.

RStudio, and Presentations, and Git! Oh my!

I have been using R for many years now and it has served me quite well.  I have used it for all manners of data prep work, analysis, developing figures, and more recently GIS and creating reproducible reports with knitr.  During this time my typical workflow included creating new folders for projects, throwing in an R shortcut that opens in the project folder directory and developing my scripts and functions with Notepad ++ (used to be TINN-R). As I was using mostly R, some LaTeX, and some Python, Notepad ++ seemed to be a good fit. I had seen a few other folks in the office using RStudio, but wasn’t interested in making the switch.

So, fast forward several months. I am now more active on Twitter (@jhollist, if you are interested) and have started this blog. As a result, I am much more aware of the general goings on in the R world (HT @Rstudioapp, @ropensci, @hadleywickham, @rbloggers just to name a few). This has made me aware of the many cool things getting developed by the R Studio crew. Two that really caught my eye were Shiny and R Presentations.

Also during this time, I have been reading up on using Markdown and version control for collaborative writing (i.e. see Inundata and associated publications). The combination of these pointed towards giving RStudio and Git a try. What follows is a very abbreviated account of my experience and a few hints to get up and running.

What do you need to get up an running?

  1. Install Git:  For my setup I simply grabbed the git installer.
  2. Get a Github account: If you don’t have one already, head over to Github and set up an account.
  3. Install the preview version of RStudio (at least its a preview as of the date of this post):  The currently available RStudio Preview version is 0.98.456.  Why is this interesting?  Well,  you can create R Presentations with it.
  4. Start a version controlled project and connect it to your Github account: First, create a new repository on Github.  When that is created copy the https URL for the repository.  Second, create a new project in RStudio, selecting the “Create Project From: Version Control”.  Choose “Git” as the version control and in the “Repository URL” field put the https URL of your newly created Github repository.  You should be able to commit locally and push to your master branch on Github.
  5. Create a presentation: Now all you need to do is read up on some of the basics of R Markdown for presentations and have at it.  Once written, click on the “knit html” button and save as html.  Use that or push to web!


Most of the dithering was not at all with getting the presentations built and RStudio up and running, it was with the layout.  As I am an extreme novice with CSS it took me some time to get everything where I wanted.  But I did eventually get it set.

First thing I had to figure out was how to get changes to the CSS implemented.  From my reading I found three ways:

  1. Edit the default style sheet:  On my system, it is located at C:\Program Files\RStudio\resources\presentation\slides.css. Simply add the changes you want to the end of the file, save, and restart RStudio. Now every new presentation you start will have your slide template implemented. Couple of warnings for this. First, if you install a new version of RStudio, your customized default CSS will get overwritten. Second, and this is just good practice, save a copy of the original (or better yet, use Git to track the changes) so if you really mess up you don’t need to do a reinstall.
  2. Use a custom style sheet:  Copy the default and edit it to your liking.  Once you have that finished simply throw in the following line at the top of your presentation directly under your title slide: css: mySlideTemplate.css
  3. Add styles directly into the presentation:  As knitr converts the R Markdown into html you can simply add the styles at the top of the presentation and they will get included when you knit to html.  See the RStudio write up for more info.

Some of the changes I wanted to make were to set the backgrounds for all slides to white, add in a topbar on each slide and re-position the slide titles.

To change the title slide background color and text color:

.section .reveal .state-background {
    background: white;}
.section .reveal h1,
.section .reveal p {
    color: black;
    position: relative;
    top: 4%;}

To add a top bar:

.reveal .present {
   background: white;
   background-image: url(http://jhollist.github.io/files/images/TopBar.jpg);
   background-repeat: no-repeat;
   background-position: 0% 9.35%;
   background-size: 100%;}

And to move the slide title but not the subsequent h3 tags:

.reveal h3{
   position: relative;
   top: 0%;
   left: 0%;}
.reveal .slideContent h3{
   left: 0%;}

What I would like to see added:

Two things that I tried to get working but couldn’t were more control over the positioning on some of the text (e.g. centering) and the ability to output presentations as PDF. The positioning issue is likely do to my lack of experience with Markdown. The PDF issue sounds like a common challenge with the Reveal.js based presentations. Since the R Presentations are still part of the preview, this is just me being picky.  I realize many of these kinds of issues will get worked out with future releases.


So, my verdict after a month or so with RStudio… I’m hooked.  I am now using it for presentations (just completed my third one) and to top it off, I am pushing those presentations up to my Github page (still in development) and presenting via the web.  I have created a template for the presentations that will work for what I need at work and now it is simply a matter of plugging in the text and images for my presentations.

Presentations aside, I have only had a chance for some limited analysis with RStudio (thanks government shutdown), but the editor in general is, at a minimum, on par with everything else I have tried but likely will prove to be an improvement over what I have gotten used to.

In short RStudio has a very shallow learning curve, the integrated environment makes work easy, the interface is nice, and the options (Git, Presentations, Shiny Apps, Sweave, etc.) are fantastic.  If you are thinking of making the switch, do it.

Lastly, apologies for the cheeky title.  My internal Kansan got the better of me.