update to counting

This commit is contained in:
agdamsbo 2018-10-24 12:00:53 +02:00
parent 1dbe5976e0
commit 24a7f6ffc8

View File

@ -50,12 +50,12 @@ strobe_olr<-function(meas,var,adj,data,dec=2){
nr<-c()
for (r in 1:length(levels(dat[,2]))){
vr<-levels(dat[,2])[r]
dr<-dat[dat[,2]==vr&!is.na(dat[,2]),]
vr<-levels(mn$model[,2])[r]
dr<-mn$model[mn$model[,2]==vr,]
n<-as.numeric(nrow(dr))
## Af en eller anden grund bliver der talt for mange med.
nall<-as.numeric(nrow(dat[!is.na(dat[,2]),]))
nall<-as.numeric(nrow(mn$model))
nl<-levels(m)[r]
pro<-round(n/nall*100,0)
rt<-paste0(n," (",pro,"%)")
@ -88,13 +88,13 @@ strobe_olr<-function(meas,var,adj,data,dec=2){
for (i in 1:ncol(dat2)){
if (is.factor(dat2[,i])){
vec<-dat2[,i]
vec<-ma$model[,i]
ns<-names(dat2)[i]
for (r in 1:length(levels(vec))){
vr<-levels(vec)[r]
dr<-vec[vec==vr&!is.na(vec)]
dr<-vec[vec==vr]
n<-as.numeric(length(dr))
nall<-as.numeric(nrow(dat[!is.na(dat2[,c(ns)]),]))
nall<-as.numeric(nrow(ma$model))
nl<-paste0(ns,levels(vec)[r])
pro<-round(n/nall*100,0)
rt<-paste0(n," (",pro,"%)")
@ -104,8 +104,8 @@ strobe_olr<-function(meas,var,adj,data,dec=2){
if (!is.factor(dat2[,i])){
num<-dat2[,i]
ns<-names(dat2)[i]
n<-as.numeric(nrow(dat[!is.na(dat2[,c(ns)]),]))
nall<-as.numeric(nrow(dat))
n<-as.numeric(nrow(ma$model))
nall<-as.numeric(nrow(ma$model))
pro<-round(n/nall*100,0)
rt<-paste0(n," (",pro,"%)")
nq<-rbind(nq,cbind(ns,rt))