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

(Update: The functions introduced here is deprecated now. Please use gghighlight(), which is far nicer one) 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. ... Read more