Blog Archives

Load, Save, and .rda files

April 27, 2017
By
Load, Save, and .rda files

A couple weeks ago I stumbled across a feature in R that I had never heard of before. The functions save(), load(), and the R file type .rda. The .rda files allow a user to save their R data structures such as vectors, matrices, and data frames. The file is automatically compressed, with user options

Read more »

Importing Data into R, part II

January 31, 2017
By
Importing Data into R, part II

I recently downloaded the latest version of R Studio and noticed that their import dataset functionality had changed significantly. I had previously written about this HERE and wanted to provide an update for the current version of RStudio. When you go to import data using R Studio, you get a menu like this. If you’re

Read more »

Secret Santa Picker 2 using R

December 7, 2016
By
Secret Santa Picker 2 using R

Last year I made a blog post about a Secret Santa picker HERE, but to use it required quite a bit of messing around with the code. So this year I decided to improve the whole thing by making it a function rather than a script. The function take two inputs, a list of names

Read more »

Make a bar plot with ggplot

November 11, 2016
By
Make a bar plot with ggplot

The first time I made a bar plot (column plot) with ggplot (ggplot2), I found the process was a lot harder than I wanted it to be. This post steps through building a bar plot from start to finish. First, let’s make some data. I’m going to make a vector of months, a vector of

Read more »

Importing Data into R

September 23, 2016
By
Importing Data into R

One of the most important features we need to be able to do in R is import existing data, whether it be .txt files, .csv files, or even .xls (Excel files). If we can’t import data into R, then we can’t do anything. Okay let’s get started. The spirit of this blog is that whatever

Read more »

2 y-axis plotting

August 29, 2016
By
2 y-axis plotting

A simple plotting feature we need to be able to do with R is make a 2 y-axis plot. First let’s grab some data using the built-in beaver1 and beaver2 datasets within R. Go ahead and take a look at the data by typing it into R as I have below. # Get the beaver

Read more »

ggplot2 (ggplot) Introduction

August 26, 2016
By
ggplot2 (ggplot) Introduction

In this post I’ll briefly introduce how to use ggplot2 (ggplot), which by default makes nicer looking plots than the standard R plotting functions. The first thing to know is that ggplot requires data frames work properly. It is an entirely different framework from the standard plotting functions in R. Let’s grab a default data

Read more »

Multiplication (and R data types)

July 28, 2016
By
Multiplication (and R data types)

This is a basic post about multiplication operations in R. We’re considering element-wise multiplication versus matrix multiplication. First let’s make some data: # Make some data a = c(1,2,3) b = c(2,4,6) c = cbind(a,b) x = c(2,2,2) If we look at the output (c and x), we can see that c is a 3×2

Read more »

How to make a Function in R

May 6, 2016
By
How to make a Function in R

This post is meant to show R users how to make their own functions. We’ll start with an easy example below. Most of my posts provide R code that can be easily copied into R and replicated at home. This post will be a break from that process since functions require saving *.R files and

Read more »

Secret Santa Picker using R

December 12, 2015
By
Secret Santa Picker using R

Here’s a quick post on making a secret santa picker using R. The code eliminates a person from picking themselves, otherwise it’s no frills. #set the variable for the number of people npeople=5 fam=matrix(ncol=1, nrow=npeople, NA) fam="name1" fam="name2" fam="name3" fam="name4" fam="name5" fam2=matrix(ncol=1, nrow=npeople, NA) names=c("name1","name2","name3","name4","name5") for (i in 1:npeople){ #pick the first name if (i==1){

Read more »

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)