2014/12/10

4th Japan.R meeting on December, 6

We had an exciting meeting "Japan.R" with many talks on last Saturday.
(I should have made an advance notice.)

(This is the picture of our venue. Thanks FreakOut!!!)

We are so pleased that many participants(over 200!!!) enjoyed the talks and have a great relationship each other in pizza party.



The following link is the website for participants.


You can find the time table of Japan.R in the above web site:

13:00~13:30Reception
13:30~13:45Opening Talk@gepuro, @0kayu
13:45~14:15Easy to create a choropleth map with choroplethr package@AriLamstein
14:15~14:45Data science ecosystem:Approach in Opt data science lab@shsaix
14:45~15:00Break
15:00~15:30Compare Deep Learning with the other classifiers with R@TJO_datasci
15:30~16:00Machine Learning @ FreakOut (仮)@yanaoki
16:00~16:15Break
16:15~17:15Language discussion(R, SAS, python, Julia, Excel(not language...))
17:15~17:30Break
17:30~18:30Lightning Talk festivals
18:30~20:00Pizza party

One of the greatest point is that we invited @Arilamstein who developed choroplethr package and he gave his talk!!! Thanks @Arilamstein!!!

You can also find the workshops reports of Japan.R in the following links:
The second link is very useful because you can see the presentation slide uploaded online.


The next Japan.R meeting will be hold next year and I will release advance notice next time.
Needless to say, everyone is welcome to join!

We are not sure that there are a lot of guys who want to join but can not read Japanese.
If you so, please let me know.
we will write English version agendas and info for next meeting.

2014/04/12

Visualize violent crime rates in the US with choroplethr package

Visualize violent crime rates in different US States with choroplethr package I have read choroplethr package from the blog post Animated Choropleths in R a few days ago. As a another visualization tool in R language, I want to try this one.
To install the latest stable release(CRAN) type the following from an R console:
install.packages("choroplethr")
To install the development version using the devtools package from github, type the following::
library(devtools)
install_github("choroplethr", "trulia")
library(choroplethr)
It's not interesting for me to run just example codes written in choroplethr package. Instead, I used other data from rMaps package as a quick data source and visualize it!
library(devtools)
install_github("ramnathv/rCharts@dev")
install_github("ramnathv/rMaps")
Now we can use violent crime rates data in the US included in rMaps package.
We can create animated choropleths as the following page:
In my case, we just process the data and visualize it as the following simple code:
# load packages
library(rMaps)
library(choroplethr)
# initialization list and get years from violent_crime data
choropleths = list()
# Get years for loop
years <- sort(unique(violent_crime$Year))
# convert to level data
violent_crime$Crime <- cut(violent_crime$Crime, 9)
# Create choropleth component.
for (i in 1:length(years)) {
    df <- subset(violent_crime, Year == years[i])
    # We need to change the column names for choroplethr function
    colnames(df) <- c("Year", "region", "value")
    # Cut decimal off df$value <- round(df$value)
    title <- paste0("Violent crime rates: ", years[i])
    choropleths[[i]] = choroplethr(df, "state", title = title)
}
# Vizualize it!
choroplethr_animate(choropleths)
The result is published via Dropbox as the following (image)link.
Enjoy!

2014/03/23

Seamless analytical environment by WDI, dplyr, and rMaps

Recently I found that My R Guru @ramnath_vaidya is developping a new visualization package rMaps.

I was so excited when I saw it for the first time and I think that it's really awesome for plotting any data on a map.

Let me explain how we can

  • Get data(WDI package)
  • Manipulate data(dplyr package)
  • Visualize the result(rMaps package)

with greate R packages.

Except for rMaps package, you can install these packages(WDI, dplyr) from CRAN by usual way.

install.packages(c("WDI", "dplyr"))

To install rMaps package, you just write the following commands on R console.

require(devtools)
install_github("ramnathv/rCharts@dev")
install_github("ramnathv/rMaps")

(Don't forget to install “devtools” package to use install_github function.)

Now, as an example, I show you that

  • Get “CO2 emissions (kt)” data from World Bank by WDI package
  • Summarze it to by dplyr package
  • Visualize it by rMaps package

The result is shown below:

…Enjoy!!!

By the way, recently an Japanese R professional guy often posts his greate articles. I recommend you to see these articles if you are interested in visualizing and dplyr especially.

Source codes:

library(WDI)
library(rMaps)
library(dplyr)
library(countrycode)
# Get CO2 emission data from World bank
# Data source : http://data.worldbank.org/indicator/EN.ATM.CO2E.KT/
df <- WDI(country=c("all"), 
          indicator="EN.ATM.CO2E.KT", 
          start=2004, end=2013)
# Data manipulation By dplyr
data <- df %.% 
  na.omit() %.%
  #Add iso3c format country code 
  mutate(iso3c=countrycode(iso2c, "iso2c", "iso3c")) %.% 
  group_by(iso3c) %.%
  #Get the most recent CO2 emission data
  summarize(value=EN.ATM.CO2E.KT[which.max(year)])
# Visualize it by rMaps
i1 <- ichoropleth(value~iso3c, data, map="world")
i1$show("iframesrc", cdn = TRUE) # for blog post
#... or you can direct plot by just evaluating "i1" on R console.