The Search Path: How R looks for stuff

Adventures with R

The good thing about sharing your knowledge with people is that you always find yourself strangely inspired. That’s what happened to me the other day in a meeting with colleagues where I were looking at some issues we were having with a reporting format we created in R Markdown. I was trying to explain to them in simple terms the little I knew about how R’s search path works and how it access objects along that path. I typed search() and got this all too familiar output

Because of the size of my console window that day, I suddenly had an analogy for them.

I asked them to imagine that they were sitting at a desk with two drawers and suddenly started looking for a particular document. What would they do?

A desk with drawers and a chair © mattbuck 2012

The first impulse would be to start from the tabletop first. This represents .GlovalEnv

View original post 70 more words

Advertisements

Leave a comment

Filed under Uncategorized

Rename a local and remote branch in git

I found this easy-to-read blog on renaming git branches and just had to share…
The code may not render properly on this page, so I suggest you hop on over there and read it.

Multiple States Knowledge Base

If you have named a branch incorrectly AND pushed this to the remote repository follow these steps before any other developers get a chance to jump on you and give you shit for not correctly following naming conventions.

1. Rename your local branch.
If you are on the branch you want to rename:

If you are on a different branch:

2. Delete the old-name remote branch and push the new-name local branch.

3. Reset the upstream branch for the new-name local branch.
Switch to the branch and then:

View original post

Leave a comment

Filed under Uncategorized

R Packages: Solving a problem using devtools in Windows

In the introduction to his book R packages, Hadley Wickham provides a neat function for making sure that everything is set for writing your own R extensionsby simply running the devtools::has_devel(), which, if all goes well, should evaluate to TRUE.

This did not work out for me and I had to fix this problem on 2 different occasions so I felt I need to share this info in case there are others also stumped by this hurdle.

The fix I found – after a full sweaty day – was in this conversation on GitHub and I would like to break it down very quickly:

  1. Make sure you have installed Rtools from CRAN
  2. Make sure that Rtools/bin as well as Rtools/MinGW/x64/ are added to your system PATH (if you don’t know how, click here)
  3. In addition, it is recommended that you install LATEX (the link is also found on the Rtools page mentioned on No. 1)
  4. Run the following lines of code

install.packages("devtools")

library(devtools)

install_github("hadley/devtools")    # to get the latest 'pre-CRAN' package updates

find_rtools()

has_devel()    # output should be TRUE

Like I said, I had this problem on 2 different machines (Windows 7 and 10) and the same fix worked on both of them.

Cheers!

Leave a comment

Filed under Computers & Internet

Problem with stand-alone executables?

Well, I just have to share this with whosoever is desperately looking for a solution to this problem and happens to stumble across this post.

It’s not easy being a newbie in any thing, and computing is no exception.

I have written a small program that I will be using for my work in the office and which would also benefit a few staffers. I wrote it in C++ and compiled it using Visual Studio. However, I couldn’t find the executable file (*.exe) anywhere on my computer!

I went over to the MSDN site, as well as StackOverflow, looking for a solution but there was none in sight. To make matters worse, I discovered that MANY beginner programmers were facing the same issue.

Then I found this video on YouTube – and voilá! – problem solved. The answer to my question is ridiculously straightforward; indeed, ignorance is very costly.

If you’re in a bind like I was, I hope this works for you the way it did for me!

Leave a comment

Filed under Computers & Internet

My experience doing R trainings at work

Recently, the office decided to set up a small team to manage its social media presence. Because I had somewhat encouraged the development, I was asked to work with them, at least as a facilitator.

Somewhere down the line, I suggested to some on the team that they should consider carrying out analysis of the social media data, at least beyond the metrics that were already available on most of those sites.

I quickly put together a very rudimentary, but useful, Shiny app, (not without some inspiration from this guy) just to demonstrate a bit of what was possible, and they were eager for me to train them in the use of R. I will share more about the app sometime later.

Application that plots social media data

Screenshot of the Shiny app developed for the team

My aim was (and still is) to get them to a point where they could carry out basic analyses on their own and grow from there. I tried to keep the material as basic and non-intimidating as possible – some of the students admitted to a morbid fear of statistics and I didn’t want to scare them off with anything too tough.

I consider myself a beginner still, so this experience really broadened my own understanding of the language. And I had a lot of fun doing it.

Well, I put together some slides on the training sessions and felt I should share them and hopefully get some feedback. Here they are:

  1. Introduction to R Programming
  2. R Data Structures – starting them off on vectors
  3. R Data Structures (Pt. II) – diving into the basics of data frames
  4. R Data Structures (Pt. III) – examining ways of working with matrices
  5. R Data Structures (Pt. IV) – lists (and lists)

The good thing is that some friends and colleagues (outside the office) have told me that, in the coming year, they would like me to train them as well in the use of R.

It’s only an opportunity for me to, yet, learn the more.

Leave a comment

Filed under Computers & Internet