How to (correctly) load a package

Adventures with R

The great Fela sang “Teacher no teach me nonsense” .

While taking a course in Machine Learning the other day, I came across this:

To find this kind of code on a course amazed even me, an R neophyte, as there is so much wrong with this function that is wrong and it really left me puzzled. What made it worse was that the course is being organised by a highly reputable software giant.

But please, if you’re loading (or more correctly, attaching) a package within a function, do not call library(); rather make use of require(). This blog by the author of the knitr package explains it better than I ever could.

View original post


Leave a comment

Filed under Uncategorized

learn to code… code what?!


teaching kids to code has had about three stages in the world:

  1. computer classes or labs in primary schools, in the 20th century
  2. computers for developing nations initiatives like one-laptop-per-child
  3. the contemporary rasp-pi/mobile app stage

each of these stages was driven by significant changes in hardware; the first by the advent of the home (and school) pc, the second by the development of a radically inexpensive “netbook,” and the third by both smartphones and single-board computers (sbcs).

i grew up in the first of these, and taught myself to code at home. the question “code what?” was not important then; asking it would be like the j.k. rowling interview where a reporter asked: “what should kids read while waiting for your next book to come out?” a stunned rowling replied, “other… books?”

with logo, the question is answered before you start: logo lends itself most easily to making graphical designs…

View original post 610 more words

Leave a comment

Filed under Uncategorized

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

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_github("hadley/devtools")    # to get the latest 'pre-CRAN' package updates


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.


Leave a comment

Filed under Computers & Internet