Posts Tagged ‘ code ’

Error notifications from R

September 5, 2014
By
Error notifications from R

I’m enthusiastic about having R notify me when my script is done. But among my early uses of this, my script threw an error, and I never got a text or pushbullet about that. And really, I’m even more interested in being notified about such errors than anything else. It’s relatively easy to get notified […]

Read more »

Notifications from R

September 3, 2014
By
Notifications from R

You just sent a long R job running. How to know when it’s done? Have it notify you by beeping, sending you a text, or sending you a notification via pushbullet. beepr You can use Rasmus Bååth’s beepr package to have your computer play a sound. Install it from CRAN with Then, at the bottom […]

Read more »

Why hadn’t I written a function for that?

July 17, 2014
By
Why hadn’t I written a function for that?

I’m often typing the same bits of code over and over. Those bits of code really should be made into functions. For example, I’m still using base graphics. (ggplot2 is on my “to do” list, really!) Often some things will be drawn with a slight overlap of the border of the plotting region. And in […]

Read more »

hipsteR: re-educating people who learned R before it was cool

May 15, 2014
By
hipsteR: re-educating people who learned R before it was cool

This morning, I started a tutorial for folks whose knowledge of R is (like mine) stuck in 2001. Yesterday I started reading the Rcpp book, and on page 4 there’s an example using the R function replicate, which (a) I'd never heard before, and (b) is super useful. I mean, I often write code like […]

Read more »

Further points on crayon colors

May 9, 2014
By
Further points on crayon colors

I saw this great post on crayola crayon colors at the Learning R blog, reproducing a nice graph of the Crayola crayon colors over time. (Also see this even nicer version.) The Learning R post shows how to grab the crayon colors from the wikipedia page, “List of Crayola crayon colors,” directly in R. Here’s […]

Read more »

Two more points about crayon colors

May 8, 2014
By
Two more points about crayon colors

If you want to use crayon colors in R but you don’t want to rely on my R/broman package, you can just grab the code. Copy the relevant lines from the R/brocolors.R file: I spent a bit of time thinking about how best to sort the colors in a meaningful way, for the plot_crayons() function. […]

Read more »

“[” with the apply() functions, revisited

April 30, 2014
By
“[” with the apply() functions, revisited

I’d mentioned in the fall that one could use "[" in the apply-type functions, like this: I just realized that you can use this with matrices, too. If you have a list of matrices, you can pull out rows and columns with this technique. As you can see, my data isn't “tidy.”

Read more »

Summary stats for ABC

September 1, 2013
By
Summary stats for ABC

Introduction In the previous post I gave a very brief introduction to ABC, including a simple example for inferring the parameters of a Markov process given some time series observations. Towards the end of the post I observed that there were (at least!) two potential problems with scaling up the simple approach described, one relating […]

Read more »

Summary stats for ABC

September 1, 2013
By
Summary stats for ABC

Introduction In the previous post I gave a very brief introduction to ABC, including a simple example for inferring the parameters of a Markov process given some time series observations. Towards the end of the post I observed that there were (at least!) two potential problems with scaling up the simple approach described, one relating […]

Read more »

“[” and “[[” with the apply() functions

August 20, 2013
By
“[” and “[[” with the apply() functions

Did you know you can use "[" and "[[" as function names for subsetting with calls to the apply-type functions? For example, suppose you have a bunch of identifier strings like "ZYY-43S-CWA3" and you want to pull off the bit before the first hyphen ("ZYY" in this case). (For code to create random IDs like […]

Read more »


Subscribe

Email:

  Subscribe