forked from ourcodingclub/CC-7-Github
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Sample_script.R
52 lines (42 loc) · 2 KB
/
Sample_script.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
############################################################
# #
# Github practice script Coding Club 01-03-2017 #
# #
############################################################
# Add in your name
# Add in purpose of this script
# To learn about version control on github
# git config --global user.email "[email protected]"
# git config --global user.name "Your Name"
# Libraries ----
library(tidyverse)
# Functions ----
# This is a ggplot function for a nice clean theme
# HINT: use this theme when making your plot later on
theme.clean <- function(){
theme_bw()+
theme(axis.text.x=element_text(size=12, angle=45, vjust=1, hjust=1),
axis.text.y=element_text(size=12),
axis.title.x=element_text(size=14, face="plain"),
axis.title.y=element_text(size=14, face="plain"),
panel.grid.major.x=element_blank(),
panel.grid.minor.x=element_blank(),
panel.grid.minor.y=element_blank(),
panel.grid.major.y=element_blank(),
plot.margin = unit(c(0.5, 0.5, 0.5, 0.5), units = , "cm"),
plot.title = element_text(size=20, vjust=1, hjust=0.5),
legend.text = element_text(size=12, face="italic"),
legend.title = element_blank(),
legend.position=c(0.9, 0.9))
}
# Load data ----
setwd("M:/Coding Club/2017-10-18 Github/")
temp_elevation <- read.csv("temp_elevation.csv")
# Make a plot showing how soil temperature changes with elevation ----
(temp.el <- ggplot (temp_elevation, aes(x = Elevation.m, y = Soil.temp.mean)) +
geom_point(colour = "#8B4513") +
geom_smooth(method = lm, colour = "#8B4513", fill = "#8B4513", alpha = 0.6) +
labs(x = "Elevation (m)", y = "Mean soil temperature (°C)") +
theme.clean())
# Save your plot in your project directory
# Commit, pull, push!