ICYMI: Using rtweet Package Is Super Easy Now!

February 12, 2018

Since the version 0.6.0 (published on Nov 16, 2017), rtweet package no longer requires the users to create their own apps. Did you notice? I didn’t know this until the author, Michael W. Kearney, kindly answered to my silly question on GitHub. I really appreciate that he is always eager not only to maintain the code but also to communicate with lazy users like me. Then, I did a quick poll (sorry, in Japanese) about how well known is the fact. ... Read more

dplyr Doesn't Provide Full Support For S4 (For Now?)

February 12, 2018

I’ve seen sooo many (duplicated) issues on this topic were opened on dplyr’s repo and lubridate’s repo. For example, you cannot filter() intervals. Consider the data below: library(lubridate) #> Loading required package: methods #> #> Attaching package: 'lubridate' #> The following object is masked from 'package:base': #> #> date library(dplyr, warn.conflicts = FALSE) # some method of tibble() won't work for interval d <- data.frame( i = interval(ymd(10000101) + years(1:3 * 1000), ymd(10000102) + years(1:3 * 1000)), value = 1:3 ) d #> i value #> 1 2000-01-01 UTC--2000-01-02 UTC 1 #> 2 3000-01-01 UTC--3000-01-02 UTC 2 #> 3 4000-01-01 UTC--4000-01-02 UTC 3 Let’s select the second row by filter(). ... Read more

An Example Usage of ggplot_add()

November 7, 2017

A generic function ggplot_add() was added to ggplot2 by this PR: Allow addition of custom objects by thomasp85 · Pull Request #2309 · tidyverse/ggplot2 I think creating a custom Geom or Stat and its constructor (geom_*() or stat_*()) is enough for the most of the extension packages of ggplot2, but some people, including me, need this. Why are there no geom_highlight()? Here is an example code of my package gghighlight: ... Read more

Publish R Markdown to Medium via An RStudio Addin

October 26, 2017

I created an experimental package to work with Medium API. mediumr: https://github.com/yutannihilation/mediumr/ mediumr allows you to knit and post R Markdown to Medium. Installation You can install mediumr from github with: devtools::install_github("yutannihilation/mediumr") Authentication Medium API requires a self-issued API token. (While they provide OAuth method, it’s hard for R users to use it since localhost is not allowed to specify in the callback URL.) Please issue a token in “Integration tokens” section of settings and set it as a environmental variable MEDIUM_API_TOKEN. ... Read more

How Not To Knit All Rmd Files With Blogdown

October 25, 2017

Blogdown is a cool package. But, if I complain about one thing, it will be the default behaviour of build_site(), which every blogdownners should execute everytime they wants to publish a new article. As stated in the documentation, build_site() will Compile all Rmd files and build the site through Hugo. (?build_site) Compiling all Rmd files is “safe” in the sense that we can notice if some Rmd becomes impossible to compile due to some breaking changes of some package. ... Read more

dplyr::select() Accepts Characters Since Version 0.7.0

October 25, 2017

Some of my friends didn’t aware that dplyr now accepts characters. Did you? For example, this expression select(iris, Sepal.Length, Petal.Length) can be also written in this way: select(iris, "Sepal.Length", "Petal.Length") or in this way: select(iris, c("Sepal.Length", "Petal.Length")) For the semantics of select(), you can find a good explanation in the vignette. Tidyeval? You may want to write some code that selects columns programmatically using variables. x <- c("col1", "col2") select(some_data, x) But, be fareful, x can be ambiguous. ... Read more

Confession: It's Me Who Committed the Change to Suppress .Rd Diffs On GitHub

October 21, 2017

You may notice that diffs of .Rd files are suppressed by default on GitHub since some time. Do you wonder who did this? It’s me, yay! This is my pull request: Ignore roxygen2 generated files by yutannihilation · Pull Request #3373 · github/linguist Though I thought I’ve done the right thing at that time, now I’m afraid this change may be bad for some cases… After the relese of roxygen2 6. ... Read more

Use CircleCI for R Projects

October 18, 2017

Why CircleCI? Yes, I know using Travis CI is this easy, thanks to devtools package: devtools::use_travis() Travis CI is OK most of the time. Still, CircleCI has some advantages: arbitrary Docker images cool test summaries Arbitrary Docker images Compared to Travis CI, CircleCI allows the users to use any docker images. For example, my WIP package which provides DBI-compatible interface to Redash uses these images: docker: - image: rocker/tidyverse:latest - image: redis:3. ... Read more

Introduction to gghighlight: Highlight ggplot's Lines and Points with Predicates

October 6, 2017

Suppose we have a data that has too many series like this: set.seed(2) d <- purrr::map_dfr( letters, ~ data.frame(idx = 1:400, value = cumsum(runif(400, -1, 1)), type = ., stringsAsFactors = FALSE)) For such data, it is almost impossible to identify a series by its colour as their differences are so subtle. library(ggplot2) ggplot(d) + geom_line(aes(idx, value, colour = type)) Highlight lines with ggplot2 + dplyr So, I am motivated to filter data and map colour only on that, using dplyr: ... Read more


July 15, 2017

Hi! I’m Hiroaki Yutani. This blog is where I struggle to learn about R (and improve my poor English). I belong to Hoxo-m Inc., a group of R-enthusiasts in Japan. My interests are mainly focused on data visualization, data manipulation and web APIs. I maintain several R packages: datadogr: R Client for Datadog API kntnr: R Client for kintone API qiitr: R Interface to Qiita API estatapi: R Interface to e-Stat API, the one-stop service for official statistics of the Japanese government kokudosuuchi: R Interface to Kokudo Suuchi API, the GIS data service of the Japanese government