Last active
August 29, 2015 14:19
-
-
Save kchannell/794dfe1966bf52bbdb27 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Eliminate N/A values from data file | |
P <- na.omit(P[1:14]) | |
# Eliminate mean max and min from data set | |
P <- P[1:114,] | |
# Store mean max min data in separate data set | |
P_data <- P[114:116,] | |
# Convert factors to numerics | |
P[,1]<-as.character(P[,1]) | |
P[,1]<-as.numeric(P[,1]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Eliminate N/A values from data file | |
P <- na.omit(P[1:14]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Store mean max min data in separate data set | |
P_data <- P[114:116,] | |
# Eliminate mean max and min (aka: rows after 113) from data set | |
P <- P[1:113,] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Convert factors to numerics | |
P[,1]<-as.character(P[,1]) # without this- years are converted to 1-114 | |
P[,1]<-as.numeric(P[,1]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# plot Annual Precipitation | |
plot(year,ann, | |
type = "l", | |
#ylim = c(0, 1050), | |
main = 'Annual Lake Superior Basin Precipitation', | |
xlab = 'Year', | |
ylab = 'Precipitation(mm)', | |
col = "blue", | |
lwd = 2) | |
grid() | |
par(new = F) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Plot Precip values | |
# jan | |
plot(year,jan, | |
type = "l", | |
main = 'Lake Superior Basin Precipitation by Month', | |
xlab = 'Year', | |
ylab = 'Precipitation(mm)', | |
col = "green", | |
lwd = 2) | |
grid() | |
par(new = T) | |
# feb | |
plot(year,feb, | |
type = "l", | |
axes = F, | |
xlab = 'Year', | |
ylab = 'Precipitation(mm)', | |
col = "magenta", | |
lwd = 2) | |
grid() | |
par(new = T) | |
# mar | |
plot(year,mar, | |
type = "l", | |
axes = F, | |
xlab = 'Year', | |
ylab = 'Precipitation(mm)', | |
col = "orange", | |
lwd = 2) | |
grid() | |
par(new = T) | |
# apr | |
plot(year,apr, | |
type = "l", | |
axes = F, | |
xlab = 'Year', | |
ylab = 'Precipitation(mm)', | |
col = "purple", | |
lwd = 2) | |
grid() | |
par(new = T) | |
# may | |
plot(year,may, | |
type = "l", | |
axes = F, | |
xlab = 'Year', | |
ylab = 'Precipitation(mm)', | |
col = "cyan", | |
lwd = 2) | |
grid() | |
par(new = T) | |
# jun | |
plot(year,jun, | |
type = "l", | |
axes = F, | |
xlab = 'Year', | |
ylab = 'Precipitation(mm)', | |
col = "coral", | |
lwd = 2) | |
grid() | |
par(new = F) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Read xlsx file data + headers | |
P <- read.xlsx("Precip_Basin.xlsx", startRow = 4, header = TRUE, sep = ",", sheetName = 'SUP_mm') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Read xlsx file data | |
P <- read.xlsx("Precip_Basin.xlsx", sheetName = 'SUP_mm') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Set directory | |
setwd("~/1-R") | |
# install and load packages to read xlxs files | |
install.packages("xlsx") | |
library(xlsx) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Assign variables | |
year <- P[,'Year'] | |
jan <- P[,'JAN'] | |
feb <- P[,'FEB'] | |
mar <- P[,'MAR'] | |
apr <- P[,'APR'] | |
may <- P[,'MAY'] | |
jun <- P[,'JUN'] | |
ann <- P[,'Total'] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment