Author Archives: Victor Ordu

About Victor Ordu

Learning new things and growing on a daily basis - that's what life's all about!

What a “freak” occurrence taught me about installing R packages

Adventures with R

I was trying to set up a particular Rmarkdown document in such a way that other users on our team, who might not have all the necessary packages installed, could get them automatically.

The first time I tried it out it worked perfectly, but later when I re-knitted the document, this funny window popped up

R package list

I was quite surprised! Oh, what had I done now?

To cut the story short, the answer lies in the R documentation via help('install.packages'):

part documentation for R function

So, argument pkgs (3rd paragraph), when zero-length, is what produced the popup. After installing the missing packages in the first pass of the code I wrote, the vector not_installed was subsequently zero-length. As an example, when one does this…

…our listbox appears.

I therefore decided to throw in a conditional statement to skip the installation step in the event that all required packages are already present:

Done.

View original post

Advertisements

Leave a comment

Filed under Uncategorized

Why I decided to become a leader

doucefrancedotme

During one of my first stays in the US I read ‘The rise and fall of the Empires’ by historian Paul Kennedy. This was indeed a superb book. But what I learnt there was also what brought such empires up and down.

What historians have learnt behind the Napoleon story is also the talents of generals and scientists such as Dupleix, Davout, Kleber, Lannes, Lefebvre, Bessières, Champollion, Monge, Berthollet, Fourier and many other ones who have made it possible.

When seeing such a sum of talents and incredible people among the Empire leaders, I had no hesitation, I wanted to help this Empire grow, make it big and fun and build great achievements alltogether.

  1. GREAT LEADERS : I have realized along playing the Empire EK game how brilliant and thorough were many of my new friends, who have taught me so much. And they are both reactive…

View original post 254 more words

Leave a comment

Filed under Uncategorized

Dancing between character vectors and formula objects

Adventures with R

I was determined to exactly reproduce a composite box-and-whisker plot that I had been seeing in the book Introduction to Statistical Learning. The data are from a set of 3,000 observations called Smarket that is found in the R package that goes with the book, known as ISLR. It’s a pretty simple plot:

3 boxplots of stock market data

First, after loading the package with library(ISLR), one may want to take a cursory look at the data frame, which has 9 variable columns, using View(head(Smarket)).

I was able to successfully put together the plot with this code:

I realised, however, that I was seriously violating the DRY principle, so I tried to come up with a function instead. I struggled a bit with this because I didn’t know how to supply a character vector argument and place it into the “formula” bit that is required as the first argument…

View original post 110 more words

Leave a comment

Filed under Uncategorized

Grace is the ‘Jack’ of all Trades.

Indeed, with God’s help we can achieve a lot in a short time!

Believe. Aspire. Experience.

Jacks-by-Andrew-Malone-on-Flickr

This is how people work without grace. Picture this.
A certain man desires to change the tyre of his car so he proceeds to removing the bolts in the tyre. He is done but now he needs to lift the car up a bit to successfully​ remove the deflated tyre. So he seeks the assistance of two friends, both muscular.

two-muscular-men

They proceed to lift the car from the back while he removes the tyre. They lift the car up again and he inserts the new tyre, inserts the bolts and the car is ready. Everyone is sweating profusely.

man-sweaty-tired-1280

Now picture a man with grace. He wants to remove the tyre, he unbolts the tyre from the hinges and uses a simple jack to lift the car up, removes the tyre and replaces it. Simple.

The jack in this message is GRACE.

lifting_car

Hard work is good and admirable but hard work…

View original post 79 more words

1 Comment

Filed under Uncategorized

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