Reppo for internal functions.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

25 lines
566 B

\name{perc}
\alias{perc}
\title{perc}
\usage{
perc(x, per100=T)
}
\arguments{
\item{x}{A numeric vector or an R object but not a factor coercible to numeric by as.double(x).}
\item{perc}{A logical value indicating whether the result must sum 100 (TRUE) or 1 (FALSE).}
}
\description{
This function the percentages of a numeric vector.
}
\examples{
v<-c(2,5,10,3)
perc(v)
# It can be used with dplyr tables
library(tidyverse)
df<-data.frame("X"=c("A","A","B","B"), "Y"=v)
df \%>\% mutate(Y=perc(Y))
# Or it can be under 1
df \%>\% mutate(Y=perc(Y, per100=F))
}