mirror of
https://github.com/agdamsbo/daDoctoR.git
synced 2024-11-21 19:30:22 +01:00
now workning
This commit is contained in:
parent
a40092718b
commit
2fcf02d37e
@ -1,7 +1,7 @@
|
||||
Package: daDoctoR
|
||||
Type: Package
|
||||
Title: FUNCTIONS FOR HEALTH RESEARCH
|
||||
Version: 0.1.0.9033
|
||||
Version: 0.1.0.9034
|
||||
Author: c(person("Andreas", "Gammelgaard Damsbo", email = "agdamsbo@pm.me", role = c("cre", "aut")))
|
||||
Maintainer: Andreas Gammelgaard Damsbo <agdamsbo@pm.me>
|
||||
Description: I am a Danish medical doctor involved in neuropsychiatric research.
|
||||
|
@ -1,24 +1,26 @@
|
||||
#' Creates Euler model from list of identifier numbers.
|
||||
#'
|
||||
#' Calculates overlaps and uses eulerr package to create Euler/Venn-diagrams. Use plot() to create diagram.
|
||||
#' Calculates relative overlaps and uses eulerr package to create Euler/Venn-diagrams. Use plot() to create diagram.
|
||||
#' Combined with an evolved calculate.overlap() from the VennDiagram library.
|
||||
#' Up to five (5) dimensions. Limit set by the complexity of combinations. euler() supports more.
|
||||
#' @param x list of variables included. Has to be vectors of identifier numbers.
|
||||
#' @param total data.frame, vector or integer to calculate or use as total number of participants for percentage calculation.
|
||||
#' @param shape same as for euler(). These includes c("circle","ellipse").
|
||||
#' @keywords overlap
|
||||
#' @export
|
||||
|
||||
euler_plot<-function (x,shape)
|
||||
euler_plot<-function (x,total,shape="ellipse")
|
||||
{
|
||||
library(eulerr)
|
||||
sh<-shape
|
||||
tot<-total
|
||||
|
||||
if (1 == length(x)) {
|
||||
overlap <- list("A"=x)
|
||||
}
|
||||
else if (2 == length(x)) {
|
||||
overlap <- list("A" = x[[1]], "B" = x[[2]], "A&B" = intersect(x[[1]],
|
||||
x[[2]]))
|
||||
x[[2]]))
|
||||
}
|
||||
else if (3 == length(x)) {
|
||||
A <- x[[1]]
|
||||
@ -204,10 +206,20 @@ euler_plot<-function (x,shape)
|
||||
"A&B&C&D&E"= a31)
|
||||
}
|
||||
else {
|
||||
flog.error("Invalid size of input object", name = "VennDiagramLogger")
|
||||
flog.error("Invalid size of input object", name = "LazyOverlapCalculater")
|
||||
stop("Invalid size of input object")
|
||||
}
|
||||
eul <- euler(unlist(overlap, use.names=T),shape = sh)
|
||||
if (class(tot)=="vector"){
|
||||
n_all<-length(tot)}
|
||||
else if ((class(tot)=="integer"|class(tot)=="numeric")&length(tot)==1) {
|
||||
n_all<-tot}
|
||||
else if (class(tot)=="data.frame"){
|
||||
n_all<-nrow(tot)
|
||||
}
|
||||
ov<-lapply(overlap,function(x,all=n_all,dec=1){
|
||||
round(length(x)/all*100,dec)
|
||||
})
|
||||
eul <- euler(unlist(ov, use.names=T),shape = sh)
|
||||
return(eul)
|
||||
}
|
||||
|
||||
|
@ -4,15 +4,17 @@
|
||||
\alias{euler_plot}
|
||||
\title{Creates Euler model from list of identifier numbers.}
|
||||
\usage{
|
||||
euler_plot(x, shape)
|
||||
euler_plot(x, total, shape = "ellipse")
|
||||
}
|
||||
\arguments{
|
||||
\item{x}{list of variables included. Has to be vectors of identifier numbers.}
|
||||
|
||||
\item{total}{data.frame, vector or integer to calculate or use as total number of participants for percentage calculation.}
|
||||
|
||||
\item{shape}{same as for euler(). These includes c("circle","ellipse").}
|
||||
}
|
||||
\description{
|
||||
Calculates overlaps and uses eulerr package to create Euler/Venn-diagrams. Use plot() to create diagram.
|
||||
Calculates relative overlaps and uses eulerr package to create Euler/Venn-diagrams. Use plot() to create diagram.
|
||||
Combined with an evolved calculate.overlap() from the VennDiagram library.
|
||||
Up to five (5) dimensions. Limit set by the complexity of combinations. euler() supports more.
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user