Install R package - SvenGastauer/scatmod GitHub Wiki
This page provides guidance on how to install R functionality of scatmod.
devtools - Requirement to install from Github
scatmod can be installed form GitHub. This requires the devtools package.
If you don't have devtools installed yet:
# The package can be installed from Github:
# install.packages("devtools")
Install from Github using devtools
devtools changed the syntax to install from Github after the release of devtools 2.0. Please check which version of devtools you have currently installed:
packageVersion("devtools")
If you use devtools > 2.0:
#Install the package from github with vignettes
# Latest devtools syntax
#no vignettes
devtools::install_github("AustralianAntarcticDivision/ZooScatR")
#with vignettes
devtools::install_github("AustralianAntarcticDivision/ZooScatR", build_opts = c("--no-manual"))## For devtools v < 2.0
If you use devtools < 2.0:
# devtools::install_github("SvenGastauer/scatmod", build_vignettes = TRUE, force_deps=TRUE)
Dependencies
scatmod currently depends on:
- ggplot2 - for nicer plots
These dependencies should be installed automatically, if unavailable when scatmod is installed. If not, the missing libraries can be installed through:
packages <- c("ggplot2")
if (length(setdiff(packages, rownames(installed.packages()))) > 0) {
install.packages(setdiff(packages, rownames(installed.packages())))}
If you get a message such as:
WARNING: Rtools is required to build R packages, but is not currently installed.
Install Rtools by downloading the required binary package from cran:
Usage - Quick Start
For a quick start, a minimal example:
## Simulate the TS of a weakly scattering sphere for 1 and multiple frequencies
#define the variables
c_w = 1500
freqs = np.arange(.1,300,0.1)*1000
f = 200 * 1000
Range = 10
Radius = 0.01
Rho_w = 1026
g = 1.0025
h = 1.0025
# Simulation for 1 frequency
TS <- as.numeric(sapply(freqs,TS.sphere2,r=Range,a=Radius,c=c_w,h=h,g=g,rho=Rho_w))
# Simulation for a range of frequencies
TS_R <- as.numeric(sapply(freqs,TS.sphere2,r=Range,a=Radius,c=c_w,h=h,g=g,rho=Rho_w))
#create data frame with numeric values for easy plotting in ggplot
tsdat <- data.frame(cbind(freq=freqs,TS=TS_R))
tsdat$freq = as.numeric(tsdat$freq)
tsdat$TS = as.numeric(tsdat$TS)
#plot results with ggplot
ggplot(data=tsdat,aes(x=freq/1000,y=TS))+
geom_path(lwd=1,col="orange")+
xlab("Frequency [kHz]")+
ylab( expression(paste("TS [dB re 1", m^{2},"]")))+
ggtitle(paste("TS for a sphere with a =", round(a*100,2), "cm @ range =", round(r,1),"m"))+
theme_classic()+
theme(text = element_text(size=16))