From dc2d8985c11ae31565d8b9aadbf6dccbc4f418e5 Mon Sep 17 00:00:00 2001 From: agdamsbo Date: Wed, 13 Nov 2019 10:05:53 +0100 Subject: [PATCH] u --- DESCRIPTION | 2 +- R/strobe_pred.R | 21 ++++++++++++++------- man/strobe_pred.Rd | 2 +- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index abccea3..6f1f392 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: daDoctoR Type: Package Title: FUNCTIONS FOR HEALTH RESEARCH -Version: 0.1.0.9025 +Version: 0.1.0.9026 Author: c(person("Andreas", "Gammelgaard Damsbo", email = "agdamsbo@pm.me", role = c("cre", "aut"))) Maintainer: Andreas Gammelgaard Damsbo Description: I am a Danish medical doctor involved in neuropsychiatric research. diff --git a/R/strobe_pred.R b/R/strobe_pred.R index 4323e68..4004710 100644 --- a/R/strobe_pred.R +++ b/R/strobe_pred.R @@ -6,7 +6,7 @@ #' @param data dataframe of data. #' @param dec decimals for results, standard is set to 2. Mean and sd is dec-1. #' @param n.by.adj flag to indicate wether to count number of patients in adjusted model or overall for outcome meassure not NA. -#' @param p.val flag to include p-values in linear regression for now, set to FALSE as standard. +#' @param p.val flag to include p-values in table, set to FALSE as standard. #' @keywords logistic #' @export @@ -140,10 +140,10 @@ strobe_pred<-function(meas,adj,data,dec=2,n.by.adj=FALSE,p.val=FALSE){ for (i in 1:ncol(dat2)){ if (is.factor(dat2[,i])){ - rnames<-c(rnames,names(dat2)[i],paste0(names(dat2)[i],levels(dat2[,i]))) + rnames<-c(rnames,names(dat2)[i],levels(dat2[,i])) } if (!is.factor(dat2[,i])){ - rnames<-c(rnames,paste0(names(dat2)[i],".all"),names(dat2)[i]) + rnames<-c(rnames,names(dat2[i]),"Per unit increase") } } res<-cbind(aor_ci,apv) @@ -163,9 +163,16 @@ strobe_pred<-function(meas,adj,data,dec=2,n.by.adj=FALSE,p.val=FALSE){ suppressWarnings(re<-left_join(df,dfcr,by="names")) - ref<-data.frame(re[,1],re[,2],re[,5],re[,3]) + if (p.val==TRUE){ + ref<-data.frame(re[,1],re[,2],re[,5],re[,6],re[,3],re[,4]) - names(ref)<-c("Variable",paste0("N=",n.meas),"Crude OR (95 % CI)","Mutually adjusted OR (95 % CI)") + names(ref)<-c("Variable",paste0("N=",n.meas),"Crude OR (95 % CI)","p-value","Mutually adjusted OR (95 % CI)","A p-value") + } + else{ + ref<-data.frame(re[,1],re[,2],re[,5],re[,3]) + + names(ref)<-c("Variable",paste0("N=",n.meas),"Crude OR (95 % CI)","Mutually adjusted OR (95 % CI)") + } ls<-list(tbl=ref,miss,n.meas,nrow(d)) names(ls)<-c("Printable table","Deleted due to missingness in adjusted analysis","Number of outcome observations","Length of dataframe") @@ -297,10 +304,10 @@ strobe_pred<-function(meas,adj,data,dec=2,n.by.adj=FALSE,p.val=FALSE){ for (i in 1:ncol(dat2)){ if (is.factor(dat2[,i])){ - rnames<-c(rnames,names(dat2)[i],paste0(names(dat2)[i],levels(dat2[,i]))) + rnames<-c(rnames,names(dat2)[i],levels(dat2[,i])) } if (!is.factor(dat2[,i])){ - rnames<-c(rnames,paste0(names(dat2)[i],".all"),names(dat2)[i]) + rnames<-c(rnames,names(dat2[i]),"Per unit increase") } } res<-cbind(amean_ci,apv) diff --git a/man/strobe_pred.Rd b/man/strobe_pred.Rd index 067e056..c0c46a8 100644 --- a/man/strobe_pred.Rd +++ b/man/strobe_pred.Rd @@ -18,7 +18,7 @@ strobe_pred(meas, adj, data, dec = 2, n.by.adj = FALSE, \item{n.by.adj}{flag to indicate wether to count number of patients in adjusted model or overall for outcome meassure not NA.} -\item{p.val}{flag to include p-values in linear regression for now, set to FALSE as standard.} +\item{p.val}{flag to include p-values in table, set to FALSE as standard.} } \description{ Printable table of regression model according to STROBE. Includes borth bivariate and multivariate in the same table. Output is a list, with the first item being the main "output" as a dataframe. Automatically uses logistic regression model for dichotomous outcome variable and linear regression model for continous outcome variable. Linear regression will give estimated adjusted true mean in list.