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

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