Manual Scale in ggplot2Megan KressOctober 5, 2016
Manual ScaleIf you are want to use ggplot2 to plot two different data frames, you probably want the two data frames to be represented by different colors. Using the geom_point function, you can easily assign different colors to the different sets of data, but creating a legend for two different data frames in one ggplot is more less intuitive. The code below explains how to take two data frames and plot them together with a legend that explains the colors for each of the data sets. This code uses teh scale_colour_manual function from ggplot2.
R Code
0 Comments
R Tip: Linear RegressionAnonymousOctober 05, 2016Linear Regression is a common statistical tool used to determine relationships between data This RTip is modified from: http://www.apsnet.org/edcenter/advanced/topics/EcologyAndEpidemiologyInR/DiseaseProgress/Pages/LinearRegression.aspx
For example, let’s look at the relationship between girth and height of black cherry trees First, look at the data
Next, run the linear model
And view the stats
The linear fit line has an intercept of 62.0313, an slope of 1.0544, and an R2 value of 0.2697
|
Spatial Ecology @ MSUClick on "Category" below to search for R code compiled by the Zarnetske Spatial & Community Ecology Lab and students in MSU's Spatial Ecology graduate course (FOR870/FW870) Category
All
Archive
October 2016
|