https://etherpad.wikimedia.org/p/607-intro
This class will use collaborative note-taking
Research shows that this enhances learning!
It’s also a way to ask me a question during class
#subset consumptionData into mixed diet treatments only (mixed diet BOX #'s are multiples of 5)
mixedData<-consumptionData[consumptionData$BOX %% 5 == 0,]
mixedData$delta<-mixedData$ADD_WT - mixedData$REM_WT
mixedData$rate<-mixedData$delta/mixedData$days
#reshape to get species-specific consumption rate table
mixed.summary<-ddply(mixedData,.(BOX,SP_CODE),function(x){
data.frame(CONSUMPTION_RATE=mean(x$rate,na.rm=TRUE))
})
#############fit linear models (not including consumption--see below)
LMtestChange <- lm(formula = TEST_CHANGE ~ TREATMENT, data = expData, na.action = na.omit)
Code Forces You to Be Explicity About Theory
#subset consumptionData into mixed diet treatments only (mixed diet BOX #'s are multiples of 5)
mixedData<-consumptionData[consumptionData$BOX %% 5 == 0,]
mixedData$delta<-mixedData$ADD_WT - mixedData$REM_WT
mixedData$rate<-mixedData$delta/mixedData$days
#reshape to get species-specific consumption rate table
mixed.summary<-ddply(mixedData,.(BOX,SP_CODE),function(x){
data.frame(CONSUMPTION_RATE=mean(x$rate,na.rm=TRUE))
})
#############fit linear models (not including consumption--see below)
LMtestChange <- lm(formula = TEST_CHANGE ~ TREATMENT, data = expData, na.action = na.omit)
Coding is power
#subset consumptionData into mixed diet treatments only (mixed diet BOX #'s are multiples of 5)
mixedData<-consumptionData[consumptionData$BOX %% 5 == 0,]
mixedData$delta<-mixedData$ADD_WT - mixedData$REM_WT
mixedData$rate<-mixedData$delta/mixedData$days
#reshape to get species-specific consumption rate table
mixed.summary<-ddply(mixedData,.(BOX,SP_CODE),function(x){
data.frame(CONSUMPTION_RATE=mean(x$rate,na.rm=TRUE))
})
#############fit linear models (not including consumption--see below)
LMtestChange <- lm(formula = TEST_CHANGE ~ TREATMENT, data = expData, na.action = na.omit)
Repeatable Research
Data (acquisition)
How do I get good data here?
##
## Call:
## lm(formula = shoots ~ treatment.genotypes, data = eelgrass)
##
## Residuals:
## Min 1Q Median 3Q Max
## -27.473 -10.723 -1.299 8.955 35.701
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 30.664 5.324 5.760 2.73e-06 ***
## treatment.genotypes 4.635 1.401 3.308 0.00245 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 16.39 on 30 degrees of freedom
## Multiple R-squared: 0.2672, Adjusted R-squared: 0.2428
## F-statistic: 10.94 on 1 and 30 DF, p-value: 0.002449
What is your model(s)?
THEN decide on statistical approach
Can you get data to paramaterize that model?
How does biology inform your modeled results?
Name
Lab
Brief research description
Why are you here?
Whitlock, W.C. and Schluter, D. (2014) The Analysis of Biological Data, 2nd Edition.
http://whitlockschluter.zoology.ubc.ca/
Chapter 1 this week!
Grolemund, G., and Wickham, W. 2016. R for Data Science.
http://r4ds.had.co.nz
Before and After Class
Measures understanding - and attendance!
Will drop lowest two
10% of your grade
Advanced problem set
Due Nov 4th
20% of your grade
Paper due Dec 16th (but earlier fine!)
30% of your grade
Does seagrass genetic diversity increase productivity?
Literature
Observation
Disciplinary History
Fit a model(s), chosen to suit data & error generating process!
Many Methods of Sharing Data, Methods, and Results Beyond Publication
GitHub - public code repository
FigShare - share key figures, get a doi
Blog - open ‘notebook’
Dryad or Other Repository - post-publication data sharing
1+1
## [1] 2
You try - different mathematical operators
a.number<-1+1
a.number
## [1] 2
You try - what can you save as an object?
#
The text after #
is not evaluated.
#This is going to be the number two
a.number<-1+1
#####----------
# You can get creative with comments to separate code blocks
# And write a lot, which is good practice
#####----------
Your comments tell readers - including yourself - what you are doing
sin(a.number)
## [1] 0.9092974
How to get help for a function
?cos
help(cos)
??'cosine function'
head(cars, n=3) #note the n= argument!
## speed dist
## 1 4 2
## 2 4 10
## 3 7 4
Try looking at all of cars and names(cars)
plot(speed ~ dist, data=cars)
Look at ?plot to see other arguments to change appearance
You can also install packages from the command line.
install.packages('ggplot2', repos='http://cran.case.edu/', dependencies=TRUE)
Using one of the above methods, install the package ggplot2 and its dependencies now.
library(ggplot2)
qplot(dist, speed, data=cars)
2.Look at the qplot help file & demos