Skip to content

Commit

Permalink
Merge pull request #34 from philsf/release-0.6.0
Browse files Browse the repository at this point in the history
Release 0.6.0
  • Loading branch information
philsf authored Jul 1, 2018
2 parents daab016 + b6c0ae8 commit 789abc7
Show file tree
Hide file tree
Showing 18 changed files with 110 additions and 30 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: philsfmisc
Type: Package
Title: philsf's miscellaneous R functions
Version: 0.5.1
Version: 0.6.0
Authors@R: person("Felipe", "Figueiredo", email = "[email protected]", role = c("aut", "cre"))
Description: Miscellaneous R functions for convenient data analyses.
License: GPL-2
Expand Down
4 changes: 2 additions & 2 deletions R/cv2logsd.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cv2logsd <- function(CV) {
SD <- sqrt( cv2logvar(CV) )
cv2logsd <- function(x) {
SD <- sqrt( cv2logvar(x) )
SD
}
4 changes: 2 additions & 2 deletions R/cv2logvar.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cv2logvar <- function( CV ) {
VAR <- (log((CV/100)^2 + 1))/(log(10)^2)
cv2logvar <- function( x ) {
VAR <- (log((x/100)^2 + 1))/(log(10)^2)
VAR
}
8 changes: 4 additions & 4 deletions R/format.float.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
format.float <- function(value, digits = 2) {
value <- suppressWarnings(as.numeric(value))
value <- formatC(value, format = "f", digits = digits)
value
format.float <- function(x, digits = 2) {
x <- suppressWarnings(as.numeric(x))
x <- formatC(x, format = "f", digits = digits)
x
}
5 changes: 5 additions & 0 deletions R/format.pct.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
format.pct <- function(p, digits = 1, pct.symbol = TRUE) {
symbol <- "%"
if (!pct.symbol) symbol <- NULL
paste0(format.float(p*100, digits), symbol)
}
6 changes: 3 additions & 3 deletions R/geocv.R
Original file line number Diff line number Diff line change
@@ -1,4 +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)
geocv <- function(x, na.rm = TRUE) {
logsd <- sd(log10(x), na.rm = na.rm)
logsd2cv(logsd)
}
6 changes: 3 additions & 3 deletions R/geomean.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
geomean <- function(datavector) {
datavector[(datavector == 0)] <- NA # discard null values
10^mean(log10(datavector), na.rm = T)
geomean <- function(x) {
x[(x == 0)] <- NA # discard null values
10^mean(log10(x), na.rm = T)
}
4 changes: 2 additions & 2 deletions R/geosd.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
geosd <- function(datavector) {
10^sd(log10(datavector))
geosd <- function(x) {
10^sd(log10(x))
}
4 changes: 2 additions & 2 deletions R/logsd2cv.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
logsd2cv <- function(logsd, digits = 2, na.rm = TRUE) {
round(sqrt(exp((log(10)^2)*logsd^2) - 1)*100 , digits)
logsd2cv <- function(x) {
sqrt(exp((log(10)^2)*x^2) - 1)*100
}
4 changes: 2 additions & 2 deletions R/logvar2cv.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
logvar2cv <- function(var, digits = 2, na.rm = TRUE) {
round(sqrt(exp((log(10)^2)*var) - 1)*100 , digits)
logvar2cv <- function(x) {
sqrt(exp((log(10)^2)*x) - 1)*100
}
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,15 @@ To install the *development* version, use the following command:

- `format.float`
- `format.interval`
- `format.pct`
- `is.within`
- `geomean`
- `geosd`
- `geocv`
- `logsd2cv`
- `logvar2cv`
- `cv2logsd`
- `cv2logvar`
- `predint`

## Report template
Expand Down
Binary file modified inst/rmarkdown/templates/Relatorio/skeleton/misc/style.docx
100644 → 100755
Binary file not shown.
23 changes: 23 additions & 0 deletions inst/rmarkdown/templates/Relatorio/skeleton/skeleton.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,29 @@ kable(history)

---

# Assinaturas

```{r, echo=FALSE}
sig.field <- "__________________________"
date.field <- "_____________"
Stat <- c("Elaborador", "Nome", "Função", sig.field, date.field)
Reviewer <- c("Revisado por", "", "", sig.field, date.field)
Approver <- c("Verificado por", "", "", sig.field, date.field)
Final.Approver <- c("Aprovação final", "", "", sig.field, date.field)
sigs <- rbind(
Stat
, Reviewer
, Approver
, Final.Approver
)
rownames(sigs) <- NULL
colnames(sigs) <- c("Papel", "Nome", "Função", "Assinatura", "Data")
# pander(sigs, split.cells = c(9, 14, 14, 16, 8), split.table = Inf)
kable(sigs)
```

# Lista de abreviaturas

# Introdução
Expand Down
6 changes: 3 additions & 3 deletions man/format.float.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ Format numbers, given a `digits` argument as significant decimal places.
{Numbers are always assumed to be \code{\link[base]{double}}.}
}
\usage{
format.float(x)
format.float(x, digits)
}
%- maybe also 'usage' for other objects documented here.
\arguments{
\item{value}{
\item{x}{
Value to be formatted.
Input can be a numeric or character value.
}
Expand Down Expand Up @@ -62,7 +62,7 @@ format.float("1.12543")
format.float(c("1.756", "1.823"))

# Useful for data frames
DF <- data.frame(num = c(1.756, 1.823), char = c("1.756", "1.823"), stringsAsFactors = F)
DF <- data.frame(num = c(1.756, 1.823), char = c("1.756", "1.823"), stringsAsFactors = FALSE)
transform(DF, num = format.float(num), char = format.float(char))
}
% Add one or more standard keywords, see file 'KEYWORDS' in the
Expand Down
2 changes: 1 addition & 1 deletion man/format.interval.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ Felipe Figueiredo
\examples{
format.interval(c(1.756, 1.823))

format.interval(1.5, 1) # error: 1.5 is not an interval
# format.interval(1.5, 1) # error: 1.5 is not an interval

# Input is character
format.interval(c("1.756", "1.823"))
Expand Down
51 changes: 51 additions & 0 deletions man/format.pct.Rd
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
\name{format.pct}
\alias{format.pct}
%- Also NEED an '\alias' for EACH other topic documented here.
\title{
Convenience function to format proportions as percentages
}
\description{
%% ~~ A concise (1-5 lines) description of what the function does. ~~
}
\usage{
format.pct(p, digits = 1, pct.symbol = TRUE)
}
%- maybe also 'usage' for other objects documented here.
\arguments{
\item{p}{a numeric vector assumed to be a proportion.}
\item{digits}{the number of decimal digits to be used in the output.}
\item{pct.symbol}{(logical) whether or not to include the percent sign in the output.}
}
\details{
%% ~~ If necessary, more details than the description above ~~
}
\value{
A character value formatted as percentages}
\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{
format.pct(.1)
format.pct(c(.42, .99), 0)

m <- 10*matrix(c(1, 1.1, .9, 2), nrow = 2)
format.pct(fisher.test(m)$p.value)
format.pct(fisher.test(5*m)$p.value)
format.pct(fisher.test(m)$conf.int)
}
% 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
5 changes: 1 addition & 4 deletions man/geocv.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,12 @@
%% ~~ A concise (1-5 lines) description of what the function does. ~~
}
\usage{
geocv(x, digits = 2, na.rm = TRUE)
geocv(x, 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~~
Expand Down
2 changes: 1 addition & 1 deletion man/predint.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
\title{Prediction Intervals for given data
%% ~~function to do ... ~~
}
\description{Compute a prediction of a vector, which is assumed normally distributed with unknown mean and variance.
\description{Compute a prediction interval of a vector, which is assumed normally distributed with unknown mean and variance.
%% ~~ A concise (1-5 lines) description of what the function does. ~~
}
\usage{
Expand Down

0 comments on commit 789abc7

Please sign in to comment.