fix to counting. whoop whoop

This commit is contained in:
agdamsbo 2018-10-11 17:11:35 +02:00
parent 59ae3c2f99
commit 19c73b34e6
2 changed files with 14 additions and 11 deletions

View File

@ -1,7 +1,7 @@
Package: daDoctoR
Type: Package
Title: FUNCTIONS FOR HEALTH RESEARCH
Version: 0.1.0.9006
Version: 0.1.0.9007
Author@R: 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.

View File

@ -58,8 +58,8 @@ strobe_olr<-function(meas,var,adj,data,dec=2){
nall<-as.numeric(nrow(dat[!is.na(dat[,2]),]))
nl<-levels(m)[r]
pro<-round(n/nall*100,0)
n<-paste0(n," (",pro,"%)")
nr<-rbind(nr,cbind(nl,n))
rt<-paste0(n," (",pro,"%)")
nr<-rbind(nr,cbind(nl,rt))
}
mms<-data.frame(cbind(nr,or_ci,pv))
@ -92,20 +92,23 @@ strobe_olr<-function(meas,var,adj,data,dec=2){
ns<-names(dat2)[i]
for (r in 1:length(levels(vec))){
vr<-levels(vec)[r]
dr<-vec[vec==vr]
dr<-vec[vec==vr&!is.na(vec)]
n<-as.numeric(length(dr))
# nall<-as.numeric(nrow(dat[!is.na(dat2[,c(ns)]),]))
nall<-as.numeric(nrow(dat[!is.na(dat2[,c(ns)]),]))
nl<-paste0(ns,levels(vec)[r])
# pro<-round(n/nall*100,0)
# rt<-paste0(n," (",pro,"%)")
nq<-rbind(nq,cbind(nl,n))
pro<-round(n/nall*100,0)
rt<-paste0(n," (",pro,"%)")
nq<-rbind(nq,cbind(nl,rt))
}
}
if (!is.factor(dat2[,i])){
num<-dat2[,i]
ns<-names(dat2)[i]
nall<-as.numeric(nrow(dat[!is.na(dat2[,c(ns)]),]))
nq<-rbind(nq,cbind(ns,nall))
n<-as.numeric(nrow(dat[!is.na(dat2[,c(ns)]),]))
nall<-as.numeric(nrow(dat))
pro<-round(n/nall*100,0)
rt<-paste0(n," (",pro,"%)")
nq<-rbind(nq,cbind(ns,rt))
}
}
@ -122,7 +125,7 @@ strobe_olr<-function(meas,var,adj,data,dec=2){
res<-cbind(aor_ci,apv)
rest<-data.frame(names=row.names(res),res,stringsAsFactors = F)
numb<-data.frame(names=nq[,c("nl")],N=nq[,c("n")],stringsAsFactors = F)
numb<-data.frame(names=nq[,c("nl")],N=nq[,c("rt")],stringsAsFactors = F)
namt<-data.frame(names=rnames,stringsAsFactors = F)
coll<-left_join(left_join(namt,numb,by="names"),rest,by="names")