Blog Archives

Writing Pipe-friendly Functions

July 8, 2018
By

Pipes have been a fundamental aspect of computer programming for many decades. In short, the semantics of pipes can be thought of as taking the output from the left-hand side and passing it as input to the right-hand side. For example, in a linux shell, you might cat example.txt | unique | sort to take … Continue reading Writing...

Read more »

Three Deep Truths About R

June 29, 2018
By

Everything that exists in R is an object ~ John M. Chambers Everything that happens in R is the result of a function call ~ John M. Chambers Names have objects; objects don’t have names ~ Hadley Wickham So, what are the implications of these statements? Everything in R is an object NULL is an … Continue reading Three...

Read more »

I’m ‘not in’ right now…

April 29, 2018
By

Checking whether an item is in a vector or not in a vector is a common task. The notation in R is a little inelegant when expressing the “not in” condition since the negation operator (!) is separated from the … Continue reading →

Read more »

Defensively install packages in R

February 19, 2018
By

Often, your R code will rely on having one or more R packages available. A little defensive coding will save users of your code—including future-you—from having to figure out which packages you’re using and then having to manually install them. This … Continue reading →

Read more »

Getting started with R

February 19, 2018
By

Download and install R. Download and install RStudio. Read R for Data Science. R provides the backend: the programming language specification and the interpreter. RStudio provides the frontend: the user interface that allows you to interact with R, visualize data, … Continue reading →

Read more »

FizzBuzz in R

May 14, 2017
By

Functions are first class objects in R. Functions establish closures also known in R as environments. So, you can use functions to create other functions in creative ways. Here, I’ve written a function called divisor that returns a function that checks whether a given input, d, is evenly divisible by number and if so, returns string. Then I … Continue reading FizzBuzz...

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)