Month: May 2016

Simple Math Riddle

Here’s a deceptively simple riddle for you:

Using the numbers 1, 3, 4, 6 exactly once each, and any combination of +, -, *, /, plus parenthesis if you need to, try to arrive at the number: 24.

Give it a try. If you find the solution, I applaud you! (I could’t).

If you don’t (or if like to read recursive algorithms), you can find a solution in R here, where I use the superb data.tree package to do a brute-force random search.

Advertisements

Montreal: breaking & entering

I finally signed the lease for my future apartment. Now it’s time to see whether my new neighborhood is safe or not !

Rplot03

Check out the code to create the map above here.

The 4 red neighborhoods are:

  • 23: Hochelaga-Maisonneuve
  • 26: Côte-des-Neiges
  • 38: Le Plateau-Mont-Royal partie sud
  • 44: Rosemont et La Petite-Patrie

Oh and in case you’re wondering…my neighborhood is “Very low risk” 🙂

TSX Stock Scraper

Whenever I form the unfortunate idea to invest in the stock market, I first start by playing with the google finance stock screener.

This time, instead of burning my money, i thought my time would be better spent building a stock screener of my own.

The step-by-step code is here:

https://rpubs.com/artichaud1/177604

The result is data frame that looks like this:

Capture

For an example of visualization:

Capture2

In the above plot, I’ve removed outliers and displayed some stock symbols in the north-west corner, i.e. stocks with low Price/Earnings ratio and high BookValue/Price ratio.

U.S. Trade in Goods

Synopsis

After hearing Donald Trump repeat ad nauseam that “We [the U.S.] are losing in trade to China, losing to Mexico…”, I decide to check for myself !

sans-titresans-titre2

sans-titre3

  • U.S. exports to China have been steadily increasing for the last 15 years, but the imports from China have sky-rocketed during the same period.
  • Trade balance with Mexico has actually been pretty stable for the last 10 years.
  • Among the top-8 commercial partners, Canada is the 1st importer of U.S. goods. Mexico is second, China is third.
  • Exchanges with Canada have dropped sharply in 2015.

Sources:

 Code: