mirror of
https://github.com/agdamsbo/daDoctoR.git
synced 2024-11-21 19:30:22 +01:00
small updates, new function. now incl example
This commit is contained in:
parent
7f032c7dad
commit
1ede313f99
@ -1,7 +1,7 @@
|
|||||||
Package: daDoctoR
|
Package: daDoctoR
|
||||||
Type: Package
|
Type: Package
|
||||||
Title: FUNCTIONS FOR HEALTH RESEARCH
|
Title: FUNCTIONS FOR HEALTH RESEARCH
|
||||||
Version: 0.1.0.9035
|
Version: 0.1.0.9036
|
||||||
Author: c(person("Andreas", "Gammelgaard Damsbo", email = "agdamsbo@pm.me", role = c("cre", "aut")))
|
Author: c(person("Andreas", "Gammelgaard Damsbo", email = "agdamsbo@pm.me", role = c("cre", "aut")))
|
||||||
Maintainer: Andreas Gammelgaard Damsbo <agdamsbo@pm.me>
|
Maintainer: Andreas Gammelgaard Damsbo <agdamsbo@pm.me>
|
||||||
Description: I am a Danish medical doctor involved in neuropsychiatric research.
|
Description: I am a Danish medical doctor involved in neuropsychiatric research.
|
||||||
|
@ -7,6 +7,7 @@ export(col_num)
|
|||||||
export(comb_olr)
|
export(comb_olr)
|
||||||
export(cpr_check)
|
export(cpr_check)
|
||||||
export(cpr_sex)
|
export(cpr_sex)
|
||||||
|
export(cut_perc)
|
||||||
export(date_convert)
|
export(date_convert)
|
||||||
export(dob_extract_cpr)
|
export(dob_extract_cpr)
|
||||||
export(euler_plot)
|
export(euler_plot)
|
||||||
|
25
R/cut_perc.R
Normal file
25
R/cut_perc.R
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
#' Creates factor by percentile from numeric vector.
|
||||||
|
#'
|
||||||
|
#' Cuts numeric vector in equal groups set by percentile.
|
||||||
|
#' Export is af factor with numeric labels.
|
||||||
|
#' @param vec name of vector
|
||||||
|
#' @param percentile percentile for cuts. No check is made, sholud be a divisor of 1 as .25 og .1. Standard is .1 for centiles.
|
||||||
|
#' @keywords percentile
|
||||||
|
#' @export
|
||||||
|
#' @examples
|
||||||
|
#' ##Tests the function by quantiles
|
||||||
|
#' cut_perc(sample(1:100, 50, replace=TRUE),.25)
|
||||||
|
|
||||||
|
cut_perc<-function (vec,percentile=.1)
|
||||||
|
{
|
||||||
|
p=percentile
|
||||||
|
v=as.numeric(vec)
|
||||||
|
|
||||||
|
perc <- factor(
|
||||||
|
findInterval(v, c(-Inf,
|
||||||
|
quantile(v, probs=seq(from=p,to=1-p,by=p), na.rm=TRUE), Inf)),
|
||||||
|
labels=c(1:(1/p)
|
||||||
|
))
|
||||||
|
return(perc)
|
||||||
|
}
|
||||||
|
|
@ -1,5 +1,5 @@
|
|||||||
% Generated by roxygen2: do not edit by hand
|
% Generated by roxygen2: do not edit by hand
|
||||||
% Please edit documentation in R/age_calc_function.R
|
% Please edit documentation in R/age_calc.R
|
||||||
\name{age_calc}
|
\name{age_calc}
|
||||||
\alias{age_calc}
|
\alias{age_calc}
|
||||||
\title{Calculating age from date of birth}
|
\title{Calculating age from date of birth}
|
||||||
|
22
man/cut_perc.Rd
Normal file
22
man/cut_perc.Rd
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
% Generated by roxygen2: do not edit by hand
|
||||||
|
% Please edit documentation in R/cut_perc.R
|
||||||
|
\name{cut_perc}
|
||||||
|
\alias{cut_perc}
|
||||||
|
\title{Creates factor by percentile from numeric vector.}
|
||||||
|
\usage{
|
||||||
|
cut_perc(vec, percentile = 0.1)
|
||||||
|
}
|
||||||
|
\arguments{
|
||||||
|
\item{vec}{name of vector}
|
||||||
|
|
||||||
|
\item{percentile}{percentile for cuts. No check is made, sholud be a divisor of 1 as .25 og .1. Standard is .1 for centiles.}
|
||||||
|
}
|
||||||
|
\description{
|
||||||
|
Cuts numeric vector in equal groups set by percentile.
|
||||||
|
Export is af factor with numeric labels.
|
||||||
|
}
|
||||||
|
\examples{
|
||||||
|
##Tests the function by quantiles
|
||||||
|
cut_perc(sample(1:100, 50, replace=TRUE),.25)
|
||||||
|
}
|
||||||
|
\keyword{percentile}
|
Loading…
Reference in New Issue
Block a user