Blog Archives

Using a Column as a Column Index

September 20, 2018
By

We recently saw a great recurring R question: “how do you use one column to choose a different value for each row?” That is: how do you use a column as an index? Please read on for some idiomatic base R, data.table, and dplyr solutions. Let’s say we have some example data: df

Read more »

Dot-Pipe Paper Accepted by the R Journal!!!

September 17, 2018
By
Dot-Pipe Paper Accepted by the R Journal!!!

We are thrilled to announce our (my and Nina Zumel’s) paper on the dot-pipe has been accepted by the R-Journal! A huge “thank you” to the reviewers and editors for helping us with this! You can find our article here (pdf here)!

Read more »

Parameterizing with bquote

September 16, 2018
By

One thing that is sure to get lost in my long note on macros in R is just how concise and powerful macros are. The problem is macros are concise, but they do a lot for you. So you get bogged down when you explain the joke. Let’s try to be concise. Below is an … Continue reading Parameterizing...

Read more »

On “Competition” in the R Ecosystem

September 15, 2018
By

I’ve been thinking a bit on “competition” in the R ecosystem. I guess the closest I can come to a fair and coherent view on “competition” in the R ecosystem is some variation of the following. I, of course, should not be treating things as a competition. We are all doing work and hoping for … Continue reading On...

Read more »

Better R Code with wrapr Dot Arrow

September 15, 2018
By

Our R package wrapr supplies a "piping operator" that we feel is a real improvement in R code piped-style coding. The idea is: with wrapr‘s "dot arrow" pipe "%.__%" the expression "A %.__% B" is treated very much like "{. % B(.)" as a … Continue reading Better R Code with wrapr Dot Arrow

Read more »

Announcing wrapr 1.6.2

September 12, 2018
By
Announcing wrapr 1.6.2

wrapr 1.6.2 is now up on CRAN. We have some neat new features for R users to try (in addition to many earlier wrapr goodies). The first is the %in_block% alternate notation for let(). The wrapr let()-block allows easy replacement of names in name-capturing interfaces (such as transform()), as we show below. library("wrapr") column_mapping

Read more »

Practical Data Science with R2

September 12, 2018
By
Practical Data Science with R2

The secret is out: Nina Zumel and I are busy working on Practical Data Science with R2, the second edition of our best selling book on learning data science using the R language. Our publisher, Manning, has a great slide deck describing the book (and a discount code!!!) here: We also just got back our … Continue reading Practical...

Read more »

A Quick Appreciation of the R transform Function

September 10, 2018
By

R users who also use the dplyr package will be able to quickly understand the following code that adds an estimated area column to a data.frame. suppressPackageStartupMessages(library("dplyr")) iris %__% mutate( ., Petal.Area = (pi/4)*Petal.Width*Petal.Length) %__% head(.) ## Sepal.Length Sepal.Width Petal.Length Petal.Width Species Petal.Area ## 1 5.1 3.5 1.4 0.2 setosa 0.2199115 ## 2 4.9 3.0 … Continue reading A...

Read more »

R Tip: Give data.table a Try

September 8, 2018
By

If your R or dplyr work is taking what you consider to be a too long (seconds instead of instant, or minutes instead of seconds, or hours instead of minutes, or a day instead of an hour) then try data.table. For some tasks data.table is routinely faster than alternatives at pretty much all scales (example … Continue reading R...

Read more »

R tip: How to Pass a formula to lm

September 1, 2018
By

R tip : how to pass a formula to lm(). Often when modeling in R one wants to build up a formula outside of the modeling call. This allows the set of columns being used to be passed around as a vector of strings, and treated as data. Being able to treat controls (such as … Continue reading R...

Read more »

Search R-bloggers


Sponsors

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)