Articles by wszafranski

Load, Save, and .rda files

April 27, 2017 | wszafranski

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 ...
[Read more...]

Importing Data into R, part II

January 31, 2017 | wszafranski

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 ...
[Read more...]

Secret Santa Picker 2 using R

December 7, 2016 | wszafranski

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 ... [Read more...]

Make a bar plot with ggplot

November 11, 2016 | wszafranski

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 ...
[Read more...]

Importing Data into R

September 23, 2016 | wszafranski

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. ...
[Read more...]

2 y-axis plotting

August 29, 2016 | wszafranski

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 ...
[Read more...]

ggplot2 (ggplot) Introduction

August 26, 2016 | wszafranski

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 ...
[Read more...]

Multiplication (and R data types)

July 28, 2016 | wszafranski

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 ... [Read more...]

How to make a Function in R

May 6, 2016 | wszafranski

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 ... [Read more...]

Secret Santa Picker using R

December 12, 2015 | wszafranski

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[1,1]="name1" fam[2,1]="name2" fam[3,1]="name3" fam[4,1]="name4" fam[5,1]="... [Read more...]

A high quality plot

October 14, 2015 | wszafranski

I’ll keep this post short and sweet. Here’s some code to get a really nice looking plot in R. It has a high pixel count to produce a high resolution output that can be used in a word document. Because of this, the size of everything in the ... [Read more...]

Plotting 2

September 22, 2015 | wszafranski

In this post we’ll cover go into more detail on plotting commands. We’ll use a scatterplot (X-Y plot) as our example plot. Again we’ll use the command plot. ##First let's make some data x
[Read more...]

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)