This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.
When you click the Knit button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:
#install.packages("dplyr")
#install.packages("tidyr")
#install.packages("ggplot2")
#install.packages("leaflet")
#install.packages("gsw")
library(tidyr)
library(dplyr)
##
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
library(ggplot2)
library(gsw)
library(leaflet)
#cd /Users/w5/Mast467/Code
#./Hw3code
#ls -la output.dat
omg <- read.csv(file="/Users/w5/Mast467/Code/output.dat",sep=" ")
ggplot(omg,aes(x=depth,y=temp)) +
geom_path() +
ylab("Temperature, C") +
xlab("Depth, m") +
coord_flip(expand=FALSE)
ggplot(omg,aes(x=depth,y=Sal)) +
geom_path() +
ylab("Salinity, PPT") +
xlab("Depth, m") +
coord_flip(expand=FALSE)
ggplot(omg,aes(x=Sal,y=temp)) +
geom_path() +
ylab("Temperature, C") +
xlab("Salinity, PPT") +
coord_flip(expand=FALSE)
ggplot(omg,aes(x=Sal,y=temp,color=depth)) +
geom_path() +
ylab("Temperature, C") +
xlab("Salinity, PPT") +
scale_color_viridis_c(guide=guide_colorbar(barheight=16.5)) +
coord_flip(expand=FALSE)
ggplot(omg,aes(x=depth,y=temp,color=Sal)) +
geom_path() +
ylab("Temperature, C") +
xlab("Depth, m") +
scale_color_viridis_c(guide=guide_colorbar(barheight=16.5)) +
coord_flip(expand=FALSE)
ggplot(omg,aes(x=depth,y=Sal,color=temp)) +
geom_path() +
ylab("Salinity, PPT") +
xlab("Depth, m") +
scale_color_viridis_c(guide=guide_colorbar(barheight=16.5)) +
coord_flip(expand=FALSE)
ggplot(omg,aes(x=depth,y=Sal,color=temp)) +
geom_path() +
ylab("Salinity, PPT") +
xlab("Depth, m") +
ylim(32,35) +
xlim(-750,0) +
scale_color_viridis_c(guide=guide_colorbar(barheight=16.5)) +
coord_flip(expand=FALSE)
## Warning: Removed 234 row(s) containing missing values (geom_path).
depth <- omg$depth
Sal <- omg$Sal
temp <- omg$temp
z=depth
p=gsw_p_from_z(z,70)
s=Sal
latitude=70.
longitude=-35.
SA=gsw_SA_from_SP(s,p,latitude,longitude)
t=temp
pt=gsw_pt_from_t(SA,t,p,0)
CT=gsw_CT_from_t(SA,t,p)
r0=gsw_sigma0(SA,CT)
r1=gsw_sigma1(SA,CT)
tf=gsw_CT_freezing(SA,p,1)
omg1 <- data.frame (pt,r0,r1,s,SA,t,tf,z,CT,depth,temp,Sal,p)
#library(dplyr)
#vector(mode = "logical", length = 0)
depth <- omg$depth
Sal <- omg$Sal
temp <- omg$temp
pt <- omg1$pt
r0 <- omg1$r0
r1 <- omg1$r1
s <- omg1$s
SA <- omg1$SA
t <- omg1$t
tf <- omg1$tf
z <- omg1$z
CT <- omg1$CT
depth <- omg1$depth
temp <- omg1$temp
Sal <- omg1$Sal
p <- omg1$p
#as.vector(x, mode = "")
#mutate(omg, depth=)
ggplot(omg1,aes(x=SA,y=z)) +
geom_path() +
ylab("Depth, m") +
xlab("Absolute Salinity, PSU") +
ylim(-750,0) +
xlim(25,35)
## Warning: Removed 2677 row(s) containing missing values (geom_path).
ggplot(omg1,aes(x=temp,y=pt)) +
geom_path() +
ylab("Potential Temperature, C") +
xlab("Temperature, c") +
ylim(-2.5,6) +
xlim(-2.5,6)
ggplot(omg1,aes(x=SA,y=r1)) +
geom_path() +
ylab("Potential density, kg/m^3 +1000") +
xlab("Absolute Salinity, PSU") +
ylim(23,33) +
xlim(25,35)
## Warning: Removed 2677 row(s) containing missing values (geom_path).
ggplot(omg1,aes(x=r1,y=SA,)) +
geom_path() +
ylab("Absolute Salinity, PPT") +
xlab("Potential Density, kg/m^3+1000") +
ylim(23,35) +
xlim(23,35)
## Warning: Removed 2677 row(s) containing missing values (geom_path).
ggplot(omg1,aes(x=CT,y=SA,)) +
geom_path() +
ylab("Absolute Salinity, PPT") +
xlab("Conservative Temperature, C") +
ylim(23,35) +
xlim(-1,5) +
coord_flip(expand=FALSE)
## Warning: Removed 2677 row(s) containing missing values (geom_path).
#install.packages("matrixStats")
library(matrixStats)
##
## Attaching package: 'matrixStats'
## The following object is masked from 'package:dplyr':
##
## count
for (i in 49:50)
{ data <- filter(omg,cast == 1)
#if (head(depth, n >=10))
print(i)
depth <- as.numeric(data[,3])
temp <- as.numeric(data[,4])
Sal <- as.numeric(data[,5])
maxdepth <- as.integer(tail(depth,i))
print(maxdepth)
#dmax=0
#if(maxdepth >= dmax)
#{ dmax = maxdepth}
#bindepth <- seq(-2,maxdepth,1)
#binSal <- binMeans(Sal,x=depth,bx=bindepth,na.rm=TRUE)
#bintemp <- binMeans(temp,x=depth,bx=bindepth,na.rm=TRUE)
#BinMetrics <- data.frame(bindepth[-2:maxdepth],binSal[-2:maxdepth],bintemp[-2:maxdepth])
}
## [1] 49
## integer(0)
## [1] 50
## integer(0)
You can also embed plots, for example:
Note that the echo = FALSE
parameter was added to the code chunk to prevent printing of the R code that generated the plot.