Here is an example how easy it is to use
cdata to re-layout your data.
Tim Morris recently tweeted the following problem (corrected).
Please will you take pity on me #rstats folks?
I only want to reshape two variables x & y from wide to long!
d xa xb ya yb
1 1 3 6 8
2 2 4 7 9
How can I get to:
id t x y
1 a 1 6
1 b 3 8
2 a 2 7
2 b 4 9
In Stata it's:
. reshape long x y, i(id) j(t) string
In R, it's:
. an hour of cursing followed by a desperate tweet 👆
Thanks for any help!
PS – I can make reshape() or gather() work when I have just x or just y.
This is not to make fun of Tim Morris: the above should be easy. Using diagrams and slowing down the data transform into small steps makes the process very easy.
Continue reading Controlling Data Layout With cdata
cdata implements an operator notation for data transform.
The idea is simple, yet powerful.
Continue reading Operator Notation for Data Transforms
Recently ran into something interesting in the
R macros/quasi-quotation/substitution/syntax front:
Romain François: “.@_lionelhenry reveals planned double curly syntax At #satRdayParis as a possible replacement, addition to !! and enquo()”
!! is no longer the last word in substitution (it certainly wasn’t the first).
Continue reading More on Macros in R
To make getting started with
rquery (an advanced query generator for
R) easier we have re-worked the package
README for various data-sources (including
Continue reading Getting Started With rquery
Recently Hadley Wickham prescribed pronouncing the
magrittr pipe as “then” and using right-assignment as follows:
I am not sure if it is a good or bad idea. But let’s play with it a bit, and perhaps readers can submit their experience and opinions in the comments section.
Continue reading Playing With Pipe Notations
While developing the
R package I took a little extra time to port the core algorithm from
C++ to both
This means I can time the exact same algorithm implemented nearly identically in each of these three languages. So I can extract some comparative “apples to apples” timings. Please read on for a summary of the results.
Continue reading Timing the Same Algorithm in R, Python, and C++
In our last note we used
wrapr::qe() to help quote expressions. In this note we will discuss quoting and code-capturing interfaces (interfaces that capture user source code) a bit more.
Continue reading Quoting Concatenate
R are popular, the most popular one being
magrittr as used by
This note will discuss the advanced re-usable piping systems:
rqdatatable operator trees and
wrapr function object pipelines. In each case we have a set of objects designed to extract extra power from the
wrapr dot-arrow pipe
Continue reading Reusable Pipelines in R
This note is a comment on some of the timings shared in the dplyr-0.8.0 pre-release announcement.
The original published timings were as follows:
With performance metrics: measurements are marketing. So let’s dig in the above a bit.
Continue reading Timing Grouped Mean Calculation in R