Logistic plot reboot

Someone asked about plotting something like this today I wrote a few functions previously to do something like this. However, since then ggplot2 has changed, and one of the functions no longer works. Hence, I fixed opts() to theme(), theme_blank() to element_blank(), and panel.background = element_blank() to plot.background = element_blank() to get the histograms to show up with the line plot and not cover it. The new functions: loghistplot <- function(data) { names(data) <- c('x','y') # rename columns # get min and max axis values min_x <- min(data$x) max_x <- max(data$x) min_y <- min(data$y) max_y <- max(data$y) # get bin numbers bin_no <- max(hist(data$x, plot = FALSE)$counts) + 5 # create plots a <- ggplot(data, aes(x = x, y = y)) + theme_bw(base_size=16) + geom_smooth(method = "glm", family = "binomial", se = TRUE, colour='black', size=1....

May 22, 2014 · 2 min · Scott Chamberlain

R ecology workshop

After my presentation yesterday to a group of grad students on R resources, I did a presentation today on intro to R data manipulation, visualizations, and analyses/visualizations of biparite networks and community level analyses (diversity, rarefaction, ordination, etc.). As I said yesterday I’ve been playing with two ways to make reproducible presentations in R: RStudio’s presentations built in to RStudio IDE, and Slidify. Yesterday I went with RStudio’s product - today I used Slidify....

July 31, 2013 · 1 min · Scott Chamberlain

ggplot2 maps with insets

UPDATE: changed data source so that the entire example can be run by anyone on their own machine. Also, per Joachim’s suggestion, I put a box around the blown up area of the map. In addition, rgeos and maptools removed, not needed. Here’s a quick demo of creating a map with an inset within it using ggplot. The inset is achieved using the gridExtra package. Install libraries install.packages(c("ggplot2", "maps", "grid", "gridExtra")) library("ggplot2") library("maps") library("grid") library("gridExtra") Create a data frame dat <- data....

August 22, 2012 · 3 min · Scott Chamberlain

Visualize your Github stats (forks and watchers) in a browser with R!

So OpenCPU is pretty awesome. You can run R in a browser using URL calls with an alphanumeric code (e.g., x3e50ee0780) defining a stored function, and any arguments you pass to it. Go here to store a function. And you can output lots of different types of things: png, pdf, json, etc - see here. Here’s a function I created (originally from https://gist.github.com/2602432): # Store a function with man lines # Go Here: http://beta....

May 5, 2012 · 2 min · Scott Chamberlain

Presenting results of logistic regression

So my advisor pointed out this ’new’ (well, 2004), way of plotting results of logistic regression results. The idea was presented in a 2004 Bulletin of the Ecological Society of America issue (here). I tried to come up with a solution using, what else, ggplot2. I don’t have it quite all the way down - I am missing the second y-axis values for the histograms, but someone smarter than me can figure that part out (note that Hadley doesn’t want to support second y-axes in ggplot2, but they can probably be hacked on)....

January 10, 2012 · 3 min · Scott Chamberlain

Weecology can has new mammal dataset

So the Weecology folks have published a large dataset on mammal communities in a data paper in Ecology. I know nothing about mammal communities, but that doesn’t mean one can’t play with the data… Their dataset consists of five csv files: communities, references, sites, species, and trapping data Where are these sites, and by the way, do they vary much in altitude? Let’s zoom in on just the states What phylogenies can we get for the species in this dataset?...

December 29, 2011 · 1 min · Scott Chamberlain

Recology is 1 yr old

This blog has lasted a whole year already. Thanks for reading and commenting. There are a couple of announcements: Less blogging: I hope to put in many more years blogging here, but in full disclosure I am blogging for Journal of Ecology now, so I am going to be (and already have been) blogging less here. More blogging: If anyone wants to write guest posts at Recology on the topics of using R for ecology and evolution, or open science, please contact me....

December 23, 2011 · 1 min · Scott Chamberlain

I Work For The Internet !

UPDATE: code and figure updated at 647 AM CST on 19 Dec ‘11. Also, see Jarrett Byrnes (improved) fork of my gist here. The site I WORK FOR THE INTERNET is collecting pictures and first names (last name initials only) to show collective support against SOPA (the Stop Online Piracy Act). Please stop by their site and add your name/picture. I used the #rstats package twitteR, created by Jeff Gentry, to search for tweets from people signing this site with their picture, then plotted using ggplot2, and also used Hadley’s lubridate to round timestamps on tweets to be able to bin tweets in to time slots for plotting....

December 13, 2011 · 1 min · Scott Chamberlain

My talk on doing phylogenetics in R

I gave a talk today on doing very basic phylogenetics in R, including getting sequence data, aligning sequence data, plotting trees, doing trait evolution stuff, etc. Please comment if you have code for doing bayesian phylogenetic inference in R. I know phyloch has function mrbayes, but can’t get it to work… Phylogenetics in R View more presentations from schamber

November 18, 2011 · 1 min · Scott Chamberlain

My little presentation on getting web data through R

With examples from rOpenSci R packages. p.s. I am no expert at this... Web data from R View more presentations from schamber

October 28, 2011 · 1 min · Scott Chamberlain