Skip to content

Commit

Permalink
Merge pull request #22 from philsf/release-0.3.0
Browse files Browse the repository at this point in the history
Release 0.3.0
  • Loading branch information
philsf authored Jan 20, 2018
2 parents 8abcf22 + 72e8e97 commit a1b8ad0
Show file tree
Hide file tree
Showing 9 changed files with 238 additions and 0 deletions.
4 changes: 4 additions & 0 deletions R/geocv.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
geocv <- function(datavector, digits = 2, na.rm = TRUE) {
logsd <- sd(log10(datavector), na.rm = na.rm)
logsd2cv(logsd, digits = digits, na.rm = na.rm)
}
4 changes: 4 additions & 0 deletions R/geomean.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
geomean <- function(datavector) {
datavector[(datavector == 0)] <- NA # discard null values
10^mean(log10(datavector), na.rm = T)
}
3 changes: 3 additions & 0 deletions R/geosd.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
geosd <- function(datavector) {
10^sd(log10(datavector))
}
3 changes: 3 additions & 0 deletions R/logsd2cv.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
logsd2cv <- function(logsd, digits = 2, na.rm = TRUE) {
round(sqrt(exp(logsd^2) - 1)*100 , digits)
}
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ To install the *development* version, use the following command:
- `format.float`
- `format.interval`
- `is.within`
- `geomean`
- `geosd`
- `geocv`
- `logsd2cv`

## Report template

Expand Down
58 changes: 58 additions & 0 deletions man/geocv.Rd
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
\name{geocv}
\alias{geocv}
%- Also NEED an '\alias' for EACH other topic documented here.
\title{Compute the CV of log-normally distributed data.
%% ~~function to do ... ~~
}
\description{
%% ~~ A concise (1-5 lines) description of what the function does. ~~
}
\usage{
geocv(x, digits = 2, na.rm = TRUE)
}
%- maybe also 'usage' for other objects documented here.
\arguments{
\item{x}{
%% ~~Describe \code{x} here~~
}
\item{digits}{
%% ~~Describe \code{digits} here~~
}
\item{na.rm}{
%% ~~Describe \code{na.rm} here~~
}
}
\details{
%% ~~ If necessary, more details than the description above ~~
}
\value{
%% ~Describe the value returned
%% If it is a LIST, use
%% \item{comp1 }{Description of 'comp1'}
%% \item{comp2 }{Description of 'comp2'}
%% ...
}
\references{
%% ~put references to the literature/web site here ~
}
\author{
%% ~~who you are~~
}
\note{
%% ~~further notes~~
}

%% ~Make other sections like Warning with \section{Warning }{....} ~

\seealso{
%% ~~objects to See Also as \code{\link{help}}, ~~~
}
\examples{
d <- c(10,100,1000)
geocv(d)
geocv(d) == logsd2cv(1)
}
% Add one or more standard keywords, see file 'KEYWORDS' in the
% R documentation directory.
\keyword{ ~kwd1 }% use one of RShowDoc("KEYWORDS")
\keyword{ ~kwd2 }% __ONLY ONE__ keyword per line
54 changes: 54 additions & 0 deletions man/geomean.Rd
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
\name{geomean}
\alias{geomean}
%- Also NEED an '\alias' for EACH other topic documented here.
\title{Compute geometric mean
%% ~~function to do ... ~~
}
\description{
%% ~~ A concise (1-5 lines) description of what the function does. ~~
}
\usage{
geomean(x)
}
%- maybe also 'usage' for other objects documented here.
\arguments{
\item{x}{vector of numeric.
%% ~~Describe \code{x} here~~
}
}
\details{
If any null values are present in \code{x} they are first replaced with \code{NA}.
}
\value{
Returns the geometric mean of \code{x}.
%% ~Describe the value returned
%% If it is a LIST, use
%% \item{comp1 }{Description of 'comp1'}
%% \item{comp2 }{Description of 'comp2'}
%% ...
}
\references{
%% ~put references to the literature/web site here ~
}
\author{
Felipe Figueiredo
}
\note{
%% ~~further notes~~
}

%% ~Make other sections like Warning with \section{Warning }{....} ~

\seealso{
%% ~~objects to See Also as \code{\link{help}}, ~~~
}
\examples{
d <- c(10,100,1000)
geomean(d)
geomean(c(d,0)) # na.rm is TRUE by default for sd()

}
% Add one or more standard keywords, see file 'KEYWORDS' in the
% R documentation directory.
\keyword{ ~kwd1 }% use one of RShowDoc("KEYWORDS")
\keyword{ ~kwd2 }% __ONLY ONE__ keyword per line
56 changes: 56 additions & 0 deletions man/geosd.Rd
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
\name{geosd}
\alias{geosd}
%- Also NEED an '\alias' for EACH other topic documented here.
\title{Compute the "geometric standard deviation" of data
%% ~~function to do ... ~~
}
\description{
The "geometric standard deviation" is not as well-defined as the geometric mean.
This function returns the analogous concept of \code{sd} in the same manner of the geometric mean.
}
\usage{
geosd(x)
}
%- maybe also 'usage' for other objects documented here.
\arguments{
\item{x}{
%% ~~Describe \code{x} here~~
}
}
\details{
%% ~~ If necessary, more details than the description above ~~
}
\value{
The anti-log of the \code{sd} of log-transformed data `x`.
Base 10 is assumed as a fixed default in this version.

%% ~Describe the value returned
%% If it is a LIST, use
%% \item{comp1 }{Description of 'comp1'}
%% \item{comp2 }{Description of 'comp2'}
%% ...
}
\references{
%% ~put references to the literature/web site here ~
}
\author{
%% ~~who you are~~
}
\note{
%% ~~further notes~~
}

%% ~Make other sections like Warning with \section{Warning }{....} ~

\seealso{
%% ~~objects to See Also as \code{\link{help}}, ~~~
\code{\link{geomean}}
}
\examples{
d <- c(10,100,1000)
geosd(d)
}
% Add one or more standard keywords, see file 'KEYWORDS' in the
% R documentation directory.
\keyword{ ~kwd1 }% use one of RShowDoc("KEYWORDS")
\keyword{ ~kwd2 }% __ONLY ONE__ keyword per line
52 changes: 52 additions & 0 deletions man/logsd2cv.Rd
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
\name{logsd2cv}
\alias{logsd2cv}
%- Also NEED an '\alias' for EACH other topic documented here.
\title{Convert the log-transformed standard deviation from a log-normal variable to the CV.
%% ~~function to do ... ~~
}
\description{
%% ~~ A concise (1-5 lines) description of what the function does. ~~
}
\usage{
logsd2cv(x)
}
%- maybe also 'usage' for other objects documented here.
\arguments{
\item{x}{
%% ~~Describe \code{x} here~~
}
}
\details{
%% ~~ If necessary, more details than the description above ~~
}
\value{
%% ~Describe the value returned
%% If it is a LIST, use
%% \item{comp1 }{Description of 'comp1'}
%% \item{comp2 }{Description of 'comp2'}
%% ...
}
\references{
%% ~put references to the literature/web site here ~
}
\author{
%% ~~who you are~~
}
\note{
%% ~~further notes~~
}

%% ~Make other sections like Warning with \section{Warning }{....} ~

\seealso{
%% ~~objects to See Also as \code{\link{help}}, ~~~
}
\examples{
d <- c(10,100,1000)
sd(log10(d)) # 1
logsd2cv(1) # 131.08\%
}
% Add one or more standard keywords, see file 'KEYWORDS' in the
% R documentation directory.
\keyword{ ~kwd1 }% use one of RShowDoc("KEYWORDS")
\keyword{ ~kwd2 }% __ONLY ONE__ keyword per line

0 comments on commit a1b8ad0

Please sign in to comment.