Added functions to convert arcminutes and arcseconds <-> degrees

Very simple stuff. Would have been nice if there was an easy
way to get arcminutes and arcseconds notation to/from degrees,
but that's a whole other can of worms. No such R packages exist
as far as I can tell. Where are all the astronomy peeps?
master
Taha Ahmed 10 months ago
parent 816d05dced
commit 6c72c0f69e

@ -1,7 +1,7 @@
Package: common
Type: Package
Title: A collection of solarchemist's common R functions
Version: 0.1.1
Version: 0.1.2
Description: A package containing solarchemist's commonly-used R functions and scripts.
Authors@R: person("Taha", "Ahmed", email = "taha@chepec.se", role = c("aut", "cre"))
License: GPL-3 + file LICENSE

@ -10,8 +10,12 @@ export(ProvideSampleId)
export(SubfigureGenerator)
export(SubstrateHistory)
export(TabularXtableHeader)
export(amin2degrees)
export(as.degrees)
export(as.radians)
export(asec2degrees)
export(degrees2amin)
export(degrees2asec)
export(int2padstr)
export(is.wholenumber)
export(molarity2mass)

@ -1,6 +1,62 @@
#' Convert arcminutes to degrees
#'
#' Convert arcminutes to degrees
#'
#' @param x arcminutes, numeric
#'
#' @seealso https://en.wikipedia.org/w/index.php?title=Minute_and_second_of_arc&oldid=1159601591
#'
#' @return degrees, numeric
#' @export
amin2degrees <- function(x) {
return (x / 60)
}
#' Convert arcseconds to degrees
#'
#' Convert arcseconds to degrees
#'
#' @param x arcseconds, numeric
#'
#' @seealso https://en.wikipedia.org/w/index.php?title=Minute_and_second_of_arc&oldid=1159601591
#'
#' @return degrees, numeric
#' @export
asec2degrees <- function(x) {
return (common::amin2degrees(x / 60))
}
#' Convert degrees to arcminutes
#'
#' Convert degrees to arcminutes
#'
#' @param x degrees, numeric
#'
#' @return arcminutes, numeric
#' @export
degrees2amin <- function(x) {
return (60 * x)
}
#' Convert degrees to arcseconds
#'
#' Convert degrees to arcseconds
#'
#' @param x degrees, numeric
#'
#' @return arcseconds, numeric
#' @export
degrees2asec <- function(x) {
return (60 * common::degrees2amin(x))
}
#' Calculate area under a curve
#'
#' Numerically calculate area under an arbitrary curve (defined by x, y coord pairs)
#' Numerically calculate area under an arbitrary curve (defined by x, y coord pairs)
#' using trapezodial integration. See Wikipedia for more info on trapz integration.
#'
#' @param x vector (of length n)

@ -36,7 +36,7 @@ I suggest the following package rebuild procedure:
+ Run `devtools::check()`.
Should complete with no warnings, errors or notes:
```
── R CMD check results ─────────────────────────────────────── common 0.1.1 ────
── R CMD check results ─────────────────────────────────────── common 0.1.2 ────
Duration: 8.1s
0 errors ✔ | 0 warnings ✔ | 0 notes ✔

@ -0,0 +1,20 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/numeric.R
\name{amin2degrees}
\alias{amin2degrees}
\title{Convert arcminutes to degrees}
\usage{
amin2degrees(x)
}
\arguments{
\item{x}{arcminutes, numeric}
}
\value{
degrees, numeric
}
\description{
Convert arcminutes to degrees
}
\seealso{
https://en.wikipedia.org/w/index.php?title=Minute_and_second_of_arc&oldid=1159601591
}

@ -0,0 +1,20 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/numeric.R
\name{asec2degrees}
\alias{asec2degrees}
\title{Convert arcseconds to degrees}
\usage{
asec2degrees(x)
}
\arguments{
\item{x}{arcseconds, numeric}
}
\value{
degrees, numeric
}
\description{
Convert arcseconds to degrees
}
\seealso{
https://en.wikipedia.org/w/index.php?title=Minute_and_second_of_arc&oldid=1159601591
}

@ -0,0 +1,17 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/numeric.R
\name{degrees2amin}
\alias{degrees2amin}
\title{Convert degrees to arcminutes}
\usage{
degrees2amin(x)
}
\arguments{
\item{x}{degrees, numeric}
}
\value{
arcminutes, numeric
}
\description{
Convert degrees to arcminutes
}

@ -0,0 +1,17 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/numeric.R
\name{degrees2asec}
\alias{degrees2asec}
\title{Convert degrees to arcseconds}
\usage{
degrees2asec(x)
}
\arguments{
\item{x}{degrees, numeric}
}
\value{
arcseconds, numeric
}
\description{
Convert degrees to arcseconds
}

@ -15,6 +15,6 @@ trapz(x, y)
vector (of length n - 1)
}
\description{
Numerically calculate area under an arbitrary curve (defined by x, y coord pairs)
Numerically calculate area under an arbitrary curve (defined by x, y coord pairs)
using trapezodial integration. See Wikipedia for more info on trapz integration.
}

Loading…
Cancel
Save