Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
eric-pedersen committed Oct 27, 2023
0 parents commit e35d486
Show file tree
Hide file tree
Showing 7 changed files with 89 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Auto detect text files and perform LF normalization
* text=auto
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.RData
.Rhistory
./Rproj.user/
*.RData
13 changes: 13 additions & 0 deletions GitTutorial.Rproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Version: 1.0

RestoreWorkspace: Default
SaveWorkspace: Default
AlwaysSaveHistory: Default

EnableCodeIndexing: Yes
UseSpacesForTab: Yes
NumSpacesForTab: 2
Encoding: UTF-8

RnwWeave: Sweave
LaTeX: pdfLaTeX
30 changes: 30 additions & 0 deletions code/analysis.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#analysis of canopy data
library(ggplot2)

source("functions.R")

#import data
canopy <- read.csv("canopy_humidity.csv")
head(canopy)

#convert units
canopy$canopy_perc_fixed <- correct_canopy(canopy$canopy_perc)
canopy$soil_hum_prop <- convert_humidity(canopy$soil_hum_perc)

head(canopy)

#visualize data
by_forest <- ggplot(aes(x=soil_hum_prop, y=canopy_perc_fixed), data=canopy)+
geom_point(aes(colour=as.factor(site_id)))+
facet_wrap(~forest_type)
by_forest

#basic analysis
lm_simple <- lm(canopy_perc_fixed~soil_hum_prop, data=canopy)
lm_simple

lm_hum_forest <- lm(canopy_perc_fixed~soil_hum_prop+forest_type, data=canopy)
lm_hum_forest
anova(lm_hum_forest)

#To be continued...
15 changes: 15 additions & 0 deletions code/functions.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Functions to help analyze data

correct_canopy <- function(x){
x <- x-5
return(x)
}

convert_humidity <- function(x){
x <- x/100
return(x)
}




25 changes: 25 additions & 0 deletions data/canopy_humidity.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
sample_id,site_id,canopy_perc,soil_hum_perc,forest_type
1,1,30,8,C
2,1,35,8.5,C
3,1,35,7.2,C
4,1,90,5.5,C
5,2,67,6.5,D
6,2,66,12.3,D
7,2,65,12.2,D
8,2,64,16.1,D
9,3,10,0.5,D
10,3,95,19.8,D
11,3,43,15.4,D
12,3,88,18.8,D
13,4,12,0.7,C
14,4,8,0.9,C
15,4,25,1.2,C
16,4,22,1.1,C
17,5,43,5.4,C
18,5,75,7.6,C
19,5,65,9.6,C
20,5,62,5.4,C
21,6,44,5.6,D
22,6,44,17.7,D
23,6,43,16.6,D
24,6,42,15.8,D
Empty file added garbage_logfile.txt
Empty file.

0 comments on commit e35d486

Please sign in to comment.