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.
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.
samchappelle.wordpress.com
Website is Moving! | Sam Chappelle's Blog
https://samchappelle.wordpress.com/2015/03/30/website-is-moving
Sam Chappelle's Blog. History doesn't repeat itself but it does rhyme. March 30, 2015. My website is moving to schapshow.com. Because apparently I’ve already purchased that domain. There’s probably a way to transfer it to the address I’m on right now, but I’m really not tech savvy enough to attempt that. Anyway, subscribe to schapshow. If you’re interested. My own domain and premium theme should make the content more visually appealing and better organized. Thanks! Simulating Waiting Times with R. Models...
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...
rforpublichealth.blogspot.com
R for Public Health: July 2013
http://rforpublichealth.blogspot.com/2013_07_01_archive.html
R for Public Health. Thursday, July 11, 2013. Let's Make a Date: Date and Time classes in R. Ok so I find in public health data that birthdays and death days are the most common dates to be dealing with. In a dataset like the DHS, dates can either be found as three separate integer variables (month, day, year) or they can be in one character variable like “05/03/2009”. So lets start with the first situation, numeric dates. Which is just in base R. ISOdate() follows the following syntax:. Dates$DOB - ISOd...
rforpublichealth.blogspot.com
R for Public Health: 3 ways that functions can improve your R code
http://rforpublichealth.blogspot.com/2014/07/3-ways-that-functions-can-improve-your.html
R for Public Health. Monday, July 7, 2014. 3 ways that functions can improve your R code. My previous blog post. Went over the basics of the syntax and debugging of user-written functions. In this post, I’ll show you examples of useful functions that you can write to make your life easier when using R. Here is the data we’ll be using for this post:. Functions to help you avoid repeating yourself. As an example, in a previous blog post I wrote about calculating robust standard errors and exporting. Well, ...
rforpublichealth.blogspot.com
R for Public Health: June 2014
http://rforpublichealth.blogspot.com/2014_06_01_archive.html
R for Public Health. Sunday, June 8, 2014. How to write and debug an R function. Basic syntax of a function. Ive been asked on a few occasions what is the deal with R user-written functions. First of all, how does the syntax work? And second of all, why would you ever want to do this? In Stata, we dont write functions; we execute built-in commands like browse. You can write your own programs that create new commands (like ado files) but its less common for users to do so. Basic syntax of a function.
SOCIAL ENGAGEMENT