petewerner.blogspot.com
Shifting sands: April 2014
http://petewerner.blogspot.com/2014_04_01_archive.html
A man with a hammer. Friday, April 25, 2014. Fractional sums of Perlin Noise. I wanted to mess around with fractional sums of Perlin noise, so made a little openFrameworks app to better understand what is going on. Frequency comes up quite a bit in the following discussion, and more or less means the rate at which something goes up and down. All you really need to keep in mind is:. High frequency noise goes up and down quickly. It looks like this (where black is 0 and white is 1):. It looks like this:.
petewerner.blogspot.com
Shifting sands: Density Plot with ggplot
http://petewerner.blogspot.com/2012/12/density-plot-with-ggplot.html
A man with a hammer. Monday, December 17, 2012. Density Plot with ggplot. This is a follow on from the post Using apply sapply and lappy in R. The dataset we are using was created like so:. M - matrix(data=cbind(rnorm(30, 0), rnorm(30, 2), rnorm(30, 5) , nrow=30, ncol=3). Three columns of 30 observations, normally distributed with means of 0, 2 and 5. We want a density plot to compare the distributions of the three columns using ggplot. First let's give our matrix some column names:. Has a partner in cri...
petewerner.blogspot.com
Shifting sands: Using apply, sapply, lapply in R
http://petewerner.blogspot.com/2012/12/using-apply-sapply-lapply-in-r.html
A man with a hammer. Monday, December 17, 2012. Using apply, sapply, lapply in R. This is an introductory post about using apply, sapply and lapply, best suited for people relatively new to R or unfamiliar with these functions. There is a part 2 coming that will look at density plots with ggplot. But first I thought I would go on a tangent to give some examples of the apply family, as they come up a lot working with R. It looked a bit like this. 1,] 005517714 0.014054038 0.017260447. M - matrix(data=cbin...
rforpublichealth.blogspot.com
R for Public Health: November 2013
http://rforpublichealth.blogspot.com/2013_11_01_archive.html
R for Public Health. Wednesday, November 13, 2013. Ggplot2: Cheatsheet for Scatterplots. Quick Intro to ggplot2. Quick Intro to ggplot2. The way ggplot2 works is by layering components of your plot on top of each other. You start with the basic of the data you want your plot to include (x and y variables), and then layer on top the kind of plotting colors/symbols you want, the look of the x- and y-axes, the background color, etc. You can also easily add regression lines and summary statistics. Package to...
rforpublichealth.blogspot.com
R for Public Health: January 2014
http://rforpublichealth.blogspot.com/2014_01_01_archive.html
R for Public Health. Thursday, January 9, 2014. Ggplot2: Cheatsheet for Barplots. Aggregate data for barplot. In the second of the series, this post will go over barplots in ggplot2. Our data is from mtcars as before. Library(ggplot2) library(gridExtra) mtc - mtcars. To introduce the barplot, I show the basic default bargraph that you would get if you indicate an x-variable and use the default geom bar. Layer, which is geom bar(stat=“bin”). You could just write geom bar(). Aggregate data for barplot.
petewerner.blogspot.com
Shifting sands: The R documentation is bad
http://petewerner.blogspot.com/2015/03/the-r-documentation-is-bad.html
A man with a hammer. Friday, March 6, 2015. The R documentation is bad. I have been using R for some time now and still can find it frustrating to work with. Over the years have come to the conclusion that it is primarily due to the documentation being bad. I offer no actual solutions here, but thought I would try and write down exactly what I dislike about it. As an example, let’s look at creating an identity matrix. Pretend we are new to R and staring at the prompt. Let’s try a search, typing? 8220;A t...
rforpublichealth.blogspot.com
R for Public Health: Animations and GIFs using ggplot2
http://rforpublichealth.blogspot.com/2014/12/animations-and-gifs-using-ggplot2.html
R for Public Health. Friday, December 26, 2014. Animations and GIFs using ggplot2. Tracing a regression line. Happy New Year plot. Happy New Year everyone! For the last post of the year, I thought I’d have a little fun with the new animation package in R. It’s actually really easy to use. I recently had some fun with it when I presented my research at an electronic poster session, and had an animated movie embedded into the powerpoint. All of the GIFs above use ggplot. 1 Tracing a regression line. But th...
rforpublichealth.blogspot.com
R for Public Health: ggplot2: Cheatsheet for Visualizing Distributions
http://rforpublichealth.blogspot.com/2014/02/ggplot2-cheatsheet-for-visualizing.html
R for Public Health. Monday, February 17, 2014. Ggplot2: Cheatsheet for Visualizing Distributions. In the third and last of the ggplot series, this post will go over interesting ways to visualize the distribution of your data. I will make up some data, and make sure to set the seed. Ive already done a post on histograms. Using base R, so I wont spend too much time on them. Here are the basics of doing them in ggplot. More on all options for histograms here. Also, I found this really great aggregation.
rforpublichealth.blogspot.com
R for Public Health: March 2015
http://rforpublichealth.blogspot.com/2015_03_01_archive.html
R for Public Health. Monday, March 9, 2015. Let’s start with what lists are and how to construct them. A list is a data structure that can hold any number of any types of other data structures. If you have vector, a dataframe, and a character object, you can put all of those into one list object like so:. Create three different classes of objects vec - 1:4 df - data.frame(y = c(1:3), x = c(m, m, f) char - Hello! 1] # [1] 1 2 3 4 # # [ 2] # y x # 1 1 m # 2 2 m # 3 3 f # # [ 3] # [1] Hello! Many ways): the...