# R/convertPressures.R In sonicscrewdriver: Bioacoustic Analysis and Publication Tools

#### Documented in convert2dyne_cm2convert2Pascals

```#' Convert pressure to Pascals
#'
#' Converts pressure measurements into Pascals
#'
#' @param P The value of the pressure to convert
#' @param input The unit of the pressure to convert, allowed values are "kPa", "dyne_cm2".
#' @export
#' @return The numeric value in Pascals
#' @examples
#' convert2Pascals(1000, input="kPa")
#' convert2Pascals(10, input="dyne_cm2")
#'
convert2Pascals <- function(P, input="kPa") {
if (input == "kPa") {
return(P*1000)
}
if (input == "dyne_cm2") {
return(P/10)
}
if (input == "Pa") {
return(P)
}
stop(paste("Unknown input to convert2Pascals:",input))
}

convert2kPascals <- function(P, input="kPa") {
return(convert2Pascals(P, input)/1000)
}

#' Convert pressure to dyne per square centimetre
#'
#' Converts pressure measurements into dyne per square centimetre
#'
#' @param P The value of the pressure to convert
#' @param input The unit of the pressure to convert, allowed values are "kPa", "P".
#' @export
#' @examples
#' convert2dyne_cm2(1, input="Pa")
#' convert2dyne_cm2(1, input="kPa")
convert2dyne_cm2 <- function(P, input="kPa") {
if (input == "kPa") {
return(P*10000)
}
if (input == "dyne_cm2") {
return(P)
}
if (input == "Pa") {
return(P*10)
}
stop(paste("Unknown input to convert2dyne_cm2:",input))
}
```

## Try the sonicscrewdriver package in your browser

Any scripts or data that you put into this service are public.

sonicscrewdriver documentation built on May 2, 2021, 5:06 p.m.