From 62376ea7756bef7a9c59bcfaac4bce305e001b38 Mon Sep 17 00:00:00 2001 From: Japal Date: Fri, 22 Dec 2023 11:42:31 +0100 Subject: [PATCH] Small update Small update of z.warning and z.delete behaviour to warn of data set containing < 2 columns/rows meeting the threshold --- .DS_Store | Bin 12292 -> 12292 bytes DESCRIPTION | 4 ++-- NEWS | 9 ++++++++- R/cmultRepl.R | 10 ++++++---- R/lrDA.R | 10 ++++++---- R/lrEM.R | 10 ++++++---- R/lrEMplus.R | 10 ++++++---- R/lrSVD.R | 10 ++++++---- R/lrSVDplus.R | 11 ++++++----- R/multKM.R | 10 ++++++---- R/multLN.R | 10 ++++++---- R/multRepl.R | 10 ++++++---- R/multReplus.R | 10 ++++++---- man/zCompositions-package.Rd | 2 +- 14 files changed, 71 insertions(+), 45 deletions(-) diff --git a/.DS_Store b/.DS_Store index b7c0f47e51871a6d06bb2d19129f7123334a994b..385105e2c57efcba05ee34fbfc5977cf897f5982 100644 GIT binary patch delta 1263 zcmbu9Uu;uV9LLZ1u59Oea@^UOn)iqSTgE4;R*sk62@jd2se{XO~)EYDSY&yL?Yv=_%n;DN6v_}e~ z`lH%kmg43$m&<&q&E-B>>-M&HtO~7NziD9e)*U5LSMOZfz?gZ-5iDB5)5Ljve^TGK zUoXrFKcyvSUAI}7(8u|>74J=@v{a=FKEy|;_=4^+9!%u5 z=))N;Zzme!+bNwgM;q#?)veqYGiMtboh_t%`FlDm6GF_zc2ChuLZpxEB9kOX=E!04 zGC4**Ag9S0@*(+zd`_;CMRJ4uKyH!S*`N$4Ta=x42MX+wOjO3opv2?^WM|qqkV~esNkWukf8)W; zTO32fBa#1ZLg$rQ+jg!-cbnzK?v4GXw=qgRP0cOdWsI8_?&>I7qTSE9SRyS#OO{;G zDP^^Ehb;p^&V?dfY0G=UoQW#wIkmhw5|k1Zv3>(%!Xe$KmRg#cJ*riTZnfL(cxle0q7~KQg~az9d)3b#hZO|3%VP;YJ%)Ac%F?gkB6_5cf&OJ1{Ca zkCizmF@qFlCF^}<){o%{Jc*|y@xypd@_s?`J}P;?jyLcYj=S+TPT(D!!C9Qcd3=PA q@fj}TYxBh#AHG|->^@b!z*++}fBr4}e)j*>XNPCO(YfY-C;1hU05JIg delta 1186 zcmchVNla5g7{|YVE#KA*CZGYg(QXtyJYP zwPSlYV&$-)R<3Ye?c5RCWb8;Ju_~=b;VtUwT}FQ_9F17cg<7qWj)2;=IojK6MB*{a zy_hv9yktV@HjB50V)3>dYO)tq|Y>nw}&~-zf>RG%_%JiB4WXsq}McK&HV%tLf ziK|U|I3Dd!yeqOC#o|+*I;4_99x9`H>Y(*xP#^84V|0Q}(kVJemuQr3(mi@ekLWQy zp-Fm0@8~^!ppW#Oe$Y?)1v^rZiZo=S0EH-qAEl^94HjS_7GoKfqXn&4g>_huZfwL> z^kFCB7{ERp3gR%1;3&@EBCg;nu3;Rva0hqs08jA@&+!(Y@daOPHXE~Xn@4zb~ zt3(#}*_)b|{$mDQ<_x?{F==EtGiPMwnxjy?s9rqc?bEVnY2sc%>5#^Fk`zdpbh$k< z3yY-bkm6Y8+!DsPjo*-L&FH)!)A%&0xSBB45~fWZYvyYjw@c-%NNt@oNlut$HZ;m- z6h5IS`SpHEti_%}e^H3K!`zU8mc0U#jpz@_$3$=r;%saJVrOIhc)HNqsH? zl6+Z${36t%4$YGOiUj>mti~Fwl^W!7Ux}6$tHyV$xWh?Vw=m)= z.warning)) { cases <- which(checkNumZerosCol/nrow(X) >= z.warning) if (z.delete == TRUE){ + if (length(cases) > (ncol(X)-2)) {stop(paste("More than 2 columns contain >",z.warning*100,"% zeros/unobserved values (see arguments z.warning and z.delete).",sep=""))} X <- X[,-cases] action <- "deleted" - warning(paste("Column no. ",cases," containing >",z.warning*100,"% zeros/unobserved values ",action," (can modify threshold using argument z.warning).\n",sep="")) + warning(paste("Column no. ",cases," containing >",z.warning*100,"% zeros/unobserved values ",action," (see arguments z.warning and z.delete).\n",sep="")) } else{ action <- "found" - stop(paste("Column no. ",cases," containing >",z.warning*100,"% zeros/unobserved values ",action," (can modify threshold using argument z.warning. Check out with zPatterns()).\n",sep="")) + stop(paste("Column no. ",cases," containing >",z.warning*100,"% zeros/unobserved values ",action," (see arguments z.warning and z.delete. Check out with zPatterns()).\n",sep="")) } } @@ -41,13 +42,14 @@ cmultRepl <- function(X,label=0,method=c("GBM","SQ","BL","CZM","user"),output=c( if (any(checkNumZerosRow/ncol(X) >= z.warning)) { cases <- which(checkNumZerosRow/ncol(X) >= z.warning) if (z.delete == TRUE){ + if (length(cases) > (nrow(X)-2)) {stop(paste("More than 2 rows contain >",z.warning*100,"% zeros/unobserved values (see arguments z.warning and z.delete).",sep=""))} X <- X[,-cases] action <- "deleted" - warning(paste("Column no. ",cases," containing >",z.warning*100,"% zeros/unobserved values ",action," (can modify threshold using argument z.warning).\n",sep="")) + warning(paste("Column no. ",cases," containing >",z.warning*100,"% zeros/unobserved values ",action," (see arguments z.warning and z.delete).\n",sep="")) } else{ action <- "found" - stop(paste("Column no. ",cases," containing >",z.warning*100,"% zeros/unobserved values ",action," (can modify threshold using argument z.warning. Check out with zPatterns()).\n",sep="")) + stop(paste("Column no. ",cases," containing >",z.warning*100,"% zeros/unobserved values ",action," (see arguments z.warning and z.delete. Check out with zPatterns()).\n",sep="")) } } diff --git a/R/lrDA.R b/R/lrDA.R index 28baf7d..ab9feb2 100644 --- a/R/lrDA.R +++ b/R/lrDA.R @@ -158,13 +158,14 @@ lrDA <- if (any(checkNumZerosCol/nrow(X) >= z.warning)) { cases <- which(checkNumZerosCol/nrow(X) >= z.warning) if (z.delete == TRUE){ + if (length(cases) > (ncol(X)-2)) {stop(paste("More than 2 columns contain >",z.warning*100,"% zeros/unobserved values (see arguments z.warning and z.delete).",sep=""))} X <- X[,-cases] action <- "deleted" - warning(paste("Column no. ",cases," containing >",z.warning*100,"% zeros/unobserved values ",action," (can modify threshold using argument z.warning).\n",sep="")) + warning(paste("Column no. ",cases," containing >",z.warning*100,"% zeros/unobserved values ",action," (see arguments z.warning and z.delete).\n",sep="")) } else{ action <- "found" - stop(paste("Column no. ",cases," containing >",z.warning*100,"% zeros/unobserved values ",action," (can modify threshold using argument z.warning. Check out with zPatterns()).\n",sep="")) + stop(paste("Column no. ",cases," containing >",z.warning*100,"% zeros/unobserved values ",action," (see arguments z.warning and z.delete. Check out with zPatterns()).\n",sep="")) } } @@ -172,13 +173,14 @@ lrDA <- if (any(checkNumZerosRow/ncol(X) >= z.warning)) { cases <- which(checkNumZerosRow/ncol(X) >= z.warning) if (z.delete == TRUE){ + if (length(cases) > (nrow(X)-2)) {stop(paste("More than 2 rows contain >",z.warning*100,"% zeros/unobserved values (see arguments z.warning and z.delete).",sep=""))} X <- X[,-cases] action <- "deleted" - warning(paste("Column no. ",cases," containing >",z.warning*100,"% zeros/unobserved values ",action," (can modify threshold using argument z.warning).\n",sep="")) + warning(paste("Column no. ",cases," containing >",z.warning*100,"% zeros/unobserved values ",action," (see arguments z.warning and z.delete).\n",sep="")) } else{ action <- "found" - stop(paste("Column no. ",cases," containing >",z.warning*100,"% zeros/unobserved values ",action," (can modify threshold using argument z.warning. Check out with zPatterns()).\n",sep="")) + stop(paste("Column no. ",cases," containing >",z.warning*100,"% zeros/unobserved values ",action," (see arguments z.warning and z.delete. Check out with zPatterns()).\n",sep="")) } } diff --git a/R/lrEM.R b/R/lrEM.R index f0b57e9..6541120 100644 --- a/R/lrEM.R +++ b/R/lrEM.R @@ -149,13 +149,14 @@ lrEM <- function(X,label=NULL,dl=NULL,rob=FALSE,ini.cov=c("complete.obs","multRe if (any(checkNumZerosCol/nrow(X) >= z.warning)) { cases <- which(checkNumZerosCol/nrow(X) >= z.warning) if (z.delete == TRUE){ + if (length(cases) > (ncol(X)-2)) {stop(paste("More than 2 columns contain >",z.warning*100,"% zeros/unobserved values (see arguments z.warning and z.delete).",sep=""))} X <- X[,-cases] action <- "deleted" - warning(paste("Column no. ",cases," containing >",z.warning*100,"% zeros/unobserved values ",action," (can modify threshold using argument z.warning).\n",sep="")) + warning(paste("Column no. ",cases," containing >",z.warning*100,"% zeros/unobserved values ",action," (see arguments z.warning and z.delete).\n",sep="")) } else{ action <- "found" - stop(paste("Column no. ",cases," containing >",z.warning*100,"% zeros/unobserved values ",action," (can modify threshold using argument z.warning. Check out with zPatterns()).\n",sep="")) + stop(paste("Column no. ",cases," containing >",z.warning*100,"% zeros/unobserved values ",action," (see arguments z.warning and z.delete. Check out with zPatterns()).\n",sep="")) } } @@ -163,13 +164,14 @@ lrEM <- function(X,label=NULL,dl=NULL,rob=FALSE,ini.cov=c("complete.obs","multRe if (any(checkNumZerosRow/ncol(X) >= z.warning)) { cases <- which(checkNumZerosRow/ncol(X) >= z.warning) if (z.delete == TRUE){ + if (length(cases) > (nrow(X)-2)) {stop(paste("More than 2 rows contain >",z.warning*100,"% zeros/unobserved values (see arguments z.warning and z.delete).",sep=""))} X <- X[,-cases] action <- "deleted" - warning(paste("Column no. ",cases," containing >",z.warning*100,"% zeros/unobserved values ",action," (can modify threshold using argument z.warning).\n",sep="")) + warning(paste("Column no. ",cases," containing >",z.warning*100,"% zeros/unobserved values ",action," (see arguments z.warning and z.delete).\n",sep="")) } else{ action <- "found" - stop(paste("Column no. ",cases," containing >",z.warning*100,"% zeros/unobserved values ",action," (can modify threshold using argument z.warning. Check out with zPatterns()).\n",sep="")) + stop(paste("Column no. ",cases," containing >",z.warning*100,"% zeros/unobserved values ",action," (see arguments z.warning and z.delete. Check out with zPatterns()).\n",sep="")) } } diff --git a/R/lrEMplus.R b/R/lrEMplus.R index c299014..46cdc71 100644 --- a/R/lrEMplus.R +++ b/R/lrEMplus.R @@ -40,13 +40,14 @@ lrEMplus <- function(X, dl = NULL, rob = FALSE, ini.cov = c("complete.obs", "mul if (any(checkNumZerosCol/nrow(X) >= z.warning)) { cases <- which(checkNumZerosCol/nrow(X) >= z.warning) if (z.delete == TRUE){ + if (length(cases) > (ncol(X)-2)) {stop(paste("More than 2 columns contain >",z.warning*100,"% zeros/unobserved values (see arguments z.warning and z.delete).",sep=""))} X <- X[,-cases] action <- "deleted" - warning(paste("Column no. ",cases," containing >",z.warning*100,"% zeros/unobserved values ",action," (can modify threshold using argument z.warning).\n",sep="")) + warning(paste("Column no. ",cases," containing >",z.warning*100,"% zeros/unobserved values ",action," (see arguments z.warning and z.delete).\n",sep="")) } else{ action <- "found" - stop(paste("Column no. ",cases," containing >",z.warning*100,"% zeros/unobserved values ",action," (can modify threshold using argument z.warning. Check out with zPatterns()).\n",sep="")) + stop(paste("Column no. ",cases," containing >",z.warning*100,"% zeros/unobserved values ",action," (see arguments z.warning and z.delete. Check out with zPatterns()).\n",sep="")) } } @@ -54,13 +55,14 @@ lrEMplus <- function(X, dl = NULL, rob = FALSE, ini.cov = c("complete.obs", "mul if (any(checkNumZerosRow/ncol(X) >= z.warning)) { cases <- which(checkNumZerosRow/ncol(X) >= z.warning) if (z.delete == TRUE){ + if (length(cases) > (nrow(X)-2)) {stop(paste("More than 2 rows contain >",z.warning*100,"% zeros/unobserved values (see arguments z.warning and z.delete).",sep=""))} X <- X[,-cases] action <- "deleted" - warning(paste("Column no. ",cases," containing >",z.warning*100,"% zeros/unobserved values ",action," (can modify threshold using argument z.warning).\n",sep="")) + warning(paste("Column no. ",cases," containing >",z.warning*100,"% zeros/unobserved values ",action," (see arguments z.warning and z.delete).\n",sep="")) } else{ action <- "found" - stop(paste("Column no. ",cases," containing >",z.warning*100,"% zeros/unobserved values ",action," (can modify threshold using argument z.warning. Check out with zPatterns()).\n",sep="")) + stop(paste("Column no. ",cases," containing >",z.warning*100,"% zeros/unobserved values ",action," (see arguments z.warning and z.delete. Check out with zPatterns()).\n",sep="")) } } diff --git a/R/lrSVD.R b/R/lrSVD.R index 65eeb2e..dcc2923 100644 --- a/R/lrSVD.R +++ b/R/lrSVD.R @@ -329,13 +329,14 @@ lrSVD <- function(X, label = NULL, dl = NULL, frac = 0.65, ncp = 2, if (any(checkNumZerosCol/nrow(X) >= z.warning)) { cases <- which(checkNumZerosCol/nrow(X) >= z.warning) if (z.delete == TRUE){ + if (length(cases) > (ncol(X)-2)) {stop(paste("More than 2 columns contain >",z.warning*100,"% zeros/unobserved values (see arguments z.warning and z.delete).",sep=""))} X <- X[,-cases] action <- "deleted" - warning(paste("Column no. ",cases," containing >",z.warning*100,"% zeros/unobserved values ",action," (can modify threshold using argument z.warning).\n",sep="")) + warning(paste("Column no. ",cases," containing >",z.warning*100,"% zeros/unobserved values ",action," (see arguments z.warning and z.delete).\n",sep="")) } else{ action <- "found" - stop(paste("Column no. ",cases," containing >",z.warning*100,"% zeros/unobserved values ",action," (can modify threshold using argument z.warning. Check out with zPatterns()).\n",sep="")) + stop(paste("Column no. ",cases," containing >",z.warning*100,"% zeros/unobserved values ",action," (see arguments z.warning and z.delete. Check out with zPatterns()).\n",sep="")) } } @@ -343,13 +344,14 @@ lrSVD <- function(X, label = NULL, dl = NULL, frac = 0.65, ncp = 2, if (any(checkNumZerosRow/ncol(X) >= z.warning)) { cases <- which(checkNumZerosRow/ncol(X) >= z.warning) if (z.delete == TRUE){ + if (length(cases) > (nrow(X)-2)) {stop(paste("More than 2 rows contain >",z.warning*100,"% zeros/unobserved values (see arguments z.warning and z.delete).",sep=""))} X <- X[,-cases] action <- "deleted" - warning(paste("Column no. ",cases," containing >",z.warning*100,"% zeros/unobserved values ",action," (can modify threshold using argument z.warning).\n",sep="")) + warning(paste("Column no. ",cases," containing >",z.warning*100,"% zeros/unobserved values ",action," (see arguments z.warning and z.delete).\n",sep="")) } else{ action <- "found" - stop(paste("Column no. ",cases," containing >",z.warning*100,"% zeros/unobserved values ",action," (can modify threshold using argument z.warning. Check out with zPatterns()).\n",sep="")) + stop(paste("Column no. ",cases," containing >",z.warning*100,"% zeros/unobserved values ",action," (see arguments z.warning and z.delete. Check out with zPatterns()).\n",sep="")) } } diff --git a/R/lrSVDplus.R b/R/lrSVDplus.R index c1f0e0e..4888e49 100644 --- a/R/lrSVDplus.R +++ b/R/lrSVDplus.R @@ -353,13 +353,14 @@ lrSVDplus <- function(X, dl = NULL, frac = 0.65, ncp = 2, beta = 0.5, method = c if (any(checkNumZerosCol/nrow(X) >= z.warning)) { cases <- which(checkNumZerosCol/nrow(X) >= z.warning) if (z.delete == TRUE){ + if (length(cases) > (ncol(X)-2)) {stop(paste("More than 2 columns contain >",z.warning*100,"% zeros/unobserved values (see arguments z.warning and z.delete).",sep=""))} X <- X[,-cases] action <- "deleted" - warning(paste("Column no. ",cases," containing >",z.warning*100,"% zeros/unobserved values ",action," (can modify threshold using argument z.warning).\n",sep="")) + warning(paste("Column no. ",cases," containing >",z.warning*100,"% zeros/unobserved values ",action," (see arguments z.warning and z.delete).\n",sep="")) } else{ action <- "found" - stop(paste("Column no. ",cases," containing >",z.warning*100,"% zeros/unobserved values ",action," (can modify threshold using argument z.warning. Check out with zPatterns()).\n",sep="")) + stop(paste("Column no. ",cases," containing >",z.warning*100,"% zeros/unobserved values ",action," (see arguments z.warning and z.delete. Check out with zPatterns()).\n",sep="")) } } @@ -367,17 +368,17 @@ lrSVDplus <- function(X, dl = NULL, frac = 0.65, ncp = 2, beta = 0.5, method = c if (any(checkNumZerosRow/ncol(X) >= z.warning)) { cases <- which(checkNumZerosRow/ncol(X) >= z.warning) if (z.delete == TRUE){ + if (length(cases) > (nrow(X)-2)) {stop(paste("More than 2 rows contain >",z.warning*100,"% zeros/unobserved values (see arguments z.warning and z.delete).",sep=""))} X <- X[,-cases] action <- "deleted" - warning(paste("Column no. ",cases," containing >",z.warning*100,"% zeros/unobserved values ",action," (can modify threshold using argument z.warning).\n",sep="")) + warning(paste("Column no. ",cases," containing >",z.warning*100,"% zeros/unobserved values ",action," (see arguments z.warning and z.delete).\n",sep="")) } else{ action <- "found" - stop(paste("Column no. ",cases," containing >",z.warning*100,"% zeros/unobserved values ",action," (can modify threshold using argument z.warning. Check out with zPatterns()).\n",sep="")) + stop(paste("Column no. ",cases," containing >",z.warning*100,"% zeros/unobserved values ",action," (see arguments z.warning and z.delete. Check out with zPatterns()).\n",sep="")) } } - # Balance matrix for olr Smat <- diag(rep(1, D)) Smat[upper.tri(Smat)] <- -1 diff --git a/R/multKM.R b/R/multKM.R index 2980b08..d3b6484 100644 --- a/R/multKM.R +++ b/R/multKM.R @@ -58,13 +58,14 @@ multKM <- if (any(checkNumZerosCol/nrow(X) >= z.warning)) { cases <- which(checkNumZerosCol/nrow(X) >= z.warning) if (z.delete == TRUE){ + if (length(cases) > (ncol(X)-2)) {stop(paste("More than 2 columns contain >",z.warning*100,"% zeros/unobserved values (see arguments z.warning and z.delete).",sep=""))} X <- X[,-cases] action <- "deleted" - warning(paste("Column no. ",cases," containing >",z.warning*100,"% zeros/unobserved values ",action," (can modify threshold using argument z.warning).\n",sep="")) + warning(paste("Column no. ",cases," containing >",z.warning*100,"% zeros/unobserved values ",action," (see arguments z.warning and z.delete).\n",sep="")) } else{ action <- "found" - stop(paste("Column no. ",cases," containing >",z.warning*100,"% zeros/unobserved values ",action," (can modify threshold using argument z.warning. Check out with zPatterns()).\n",sep="")) + stop(paste("Column no. ",cases," containing >",z.warning*100,"% zeros/unobserved values ",action," (see arguments z.warning and z.delete. Check out with zPatterns()).\n",sep="")) } } @@ -72,13 +73,14 @@ multKM <- if (any(checkNumZerosRow/ncol(X) >= z.warning)) { cases <- which(checkNumZerosRow/ncol(X) >= z.warning) if (z.delete == TRUE){ + if (length(cases) > (nrow(X)-2)) {stop(paste("More than 2 rows contain >",z.warning*100,"% zeros/unobserved values (see arguments z.warning and z.delete).",sep=""))} X <- X[,-cases] action <- "deleted" - warning(paste("Column no. ",cases," containing >",z.warning*100,"% zeros/unobserved values ",action," (can modify threshold using argument z.warning).\n",sep="")) + warning(paste("Column no. ",cases," containing >",z.warning*100,"% zeros/unobserved values ",action," (see arguments z.warning and z.delete).\n",sep="")) } else{ action <- "found" - stop(paste("Column no. ",cases," containing >",z.warning*100,"% zeros/unobserved values ",action," (can modify threshold using argument z.warning. Check out with zPatterns()).\n",sep="")) + stop(paste("Column no. ",cases," containing >",z.warning*100,"% zeros/unobserved values ",action," (see arguments z.warning and z.delete. Check out with zPatterns()).\n",sep="")) } } diff --git a/R/multLN.R b/R/multLN.R index 2e69a2a..0e0e0e8 100644 --- a/R/multLN.R +++ b/R/multLN.R @@ -31,13 +31,14 @@ multLN <- if (any(checkNumZerosCol/nrow(X) >= z.warning)) { cases <- which(checkNumZerosCol/nrow(X) >= z.warning) if (z.delete == TRUE){ + if (length(cases) > (ncol(X)-2)) {stop(paste("More than 2 columns contain >",z.warning*100,"% zeros/unobserved values (see arguments z.warning and z.delete).",sep=""))} X <- X[,-cases] action <- "deleted" - warning(paste("Column no. ",cases," containing >",z.warning*100,"% zeros/unobserved values ",action," (can modify threshold using argument z.warning).\n",sep="")) + warning(paste("Column no. ",cases," containing >",z.warning*100,"% zeros/unobserved values ",action," (see arguments z.warning and z.delete).\n",sep="")) } else{ action <- "found" - stop(paste("Column no. ",cases," containing >",z.warning*100,"% zeros/unobserved values ",action," (can modify threshold using argument z.warning. Check out with zPatterns()).\n",sep="")) + stop(paste("Column no. ",cases," containing >",z.warning*100,"% zeros/unobserved values ",action," (see arguments z.warning and z.delete. Check out with zPatterns()).\n",sep="")) } } @@ -45,13 +46,14 @@ multLN <- if (any(checkNumZerosRow/ncol(X) >= z.warning)) { cases <- which(checkNumZerosRow/ncol(X) >= z.warning) if (z.delete == TRUE){ + if (length(cases) > (nrow(X)-2)) {stop(paste("More than 2 rows contain >",z.warning*100,"% zeros/unobserved values (see arguments z.warning and z.delete).",sep=""))} X <- X[,-cases] action <- "deleted" - warning(paste("Column no. ",cases," containing >",z.warning*100,"% zeros/unobserved values ",action," (can modify threshold using argument z.warning).\n",sep="")) + warning(paste("Column no. ",cases," containing >",z.warning*100,"% zeros/unobserved values ",action," (see arguments z.warning and z.delete).\n",sep="")) } else{ action <- "found" - stop(paste("Column no. ",cases," containing >",z.warning*100,"% zeros/unobserved values ",action," (can modify threshold using argument z.warning. Check out with zPatterns()).\n",sep="")) + stop(paste("Column no. ",cases," containing >",z.warning*100,"% zeros/unobserved values ",action," (see arguments z.warning and z.delete. Check out with zPatterns()).\n",sep="")) } } diff --git a/R/multRepl.R b/R/multRepl.R index 0f82255..ad18a86 100644 --- a/R/multRepl.R +++ b/R/multRepl.R @@ -56,13 +56,14 @@ multRepl <- if (any(checkNumZerosCol/nrow(X) >= z.warning)) { cases <- which(checkNumZerosCol/nrow(X) >= z.warning) if (z.delete == TRUE){ + if (length(cases) > (ncol(X)-2)) {stop(paste("More than 2 columns contain >",z.warning*100,"% zeros/unobserved values (see arguments z.warning and z.delete).",sep=""))} X <- X[,-cases] action <- "deleted" - warning(paste("Column no. ",cases," containing >",z.warning*100,"% zeros/unobserved values ",action," (can modify threshold using argument z.warning).\n",sep="")) + warning(paste("Column no. ",cases," containing >",z.warning*100,"% zeros/unobserved values ",action," (see arguments z.warning and z.delete).\n",sep="")) } else{ action <- "found" - stop(paste("Column no. ",cases," containing >",z.warning*100,"% zeros/unobserved values ",action," (can modify threshold using argument z.warning. Check out with zPatterns()).\n",sep="")) + stop(paste("Column no. ",cases," containing >",z.warning*100,"% zeros/unobserved values ",action," (see arguments z.warning and z.delete. Check out with zPatterns()).\n",sep="")) } } @@ -70,13 +71,14 @@ multRepl <- if (any(checkNumZerosRow/ncol(X) >= z.warning)) { cases <- which(checkNumZerosRow/ncol(X) >= z.warning) if (z.delete == TRUE){ + if (length(cases) > (nrow(X)-2)) {stop(paste("More than 2 rows contain >",z.warning*100,"% zeros/unobserved values (see arguments z.warning and z.delete).",sep=""))} X <- X[,-cases] action <- "deleted" - warning(paste("Column no. ",cases," containing >",z.warning*100,"% zeros/unobserved values ",action," (can modify threshold using argument z.warning).\n",sep="")) + warning(paste("Column no. ",cases," containing >",z.warning*100,"% zeros/unobserved values ",action," (see arguments z.warning and z.delete).\n",sep="")) } else{ action <- "found" - stop(paste("Column no. ",cases," containing >",z.warning*100,"% zeros/unobserved values ",action," (can modify threshold using argument z.warning. Check out with zPatterns()).\n",sep="")) + stop(paste("Column no. ",cases," containing >",z.warning*100,"% zeros/unobserved values ",action," (see arguments z.warning and z.delete. Check out with zPatterns()).\n",sep="")) } } } diff --git a/R/multReplus.R b/R/multReplus.R index 2449c6f..4efdab1 100644 --- a/R/multReplus.R +++ b/R/multReplus.R @@ -38,13 +38,14 @@ multReplus <- function(X, dl = NULL, frac = 0.65, closure = NULL, z.warning = 0. if (any(checkNumZerosCol/nrow(X) >= z.warning)) { cases <- which(checkNumZerosCol/nrow(X) >= z.warning) if (z.delete == TRUE){ + if (length(cases) > (ncol(X)-2)) {stop(paste("More than 2 columns contain >",z.warning*100,"% zeros/unobserved values (see arguments z.warning and z.delete).",sep=""))} X <- X[,-cases] action <- "deleted" - warning(paste("Column no. ",cases," containing >",z.warning*100,"% zeros/unobserved values ",action," (can modify threshold using argument z.warning).\n",sep="")) + warning(paste("Column no. ",cases," containing >",z.warning*100,"% zeros/unobserved values ",action," (see arguments z.warning and z.delete).\n",sep="")) } else{ action <- "found" - stop(paste("Column no. ",cases," containing >",z.warning*100,"% zeros/unobserved values ",action," (can modify threshold using argument z.warning. Check out with zPatterns()).\n",sep="")) + stop(paste("Column no. ",cases," containing >",z.warning*100,"% zeros/unobserved values ",action," (see arguments z.warning and z.delete. Check out with zPatterns()).\n",sep="")) } } @@ -52,13 +53,14 @@ multReplus <- function(X, dl = NULL, frac = 0.65, closure = NULL, z.warning = 0. if (any(checkNumZerosRow/ncol(X) >= z.warning)) { cases <- which(checkNumZerosRow/ncol(X) >= z.warning) if (z.delete == TRUE){ + if (length(cases) > (nrow(X)-2)) {stop(paste("More than 2 rows contain >",z.warning*100,"% zeros/unobserved values (see arguments z.warning and z.delete).",sep=""))} X <- X[,-cases] action <- "deleted" - warning(paste("Column no. ",cases," containing >",z.warning*100,"% zeros/unobserved values ",action," (can modify threshold using argument z.warning).\n",sep="")) + warning(paste("Column no. ",cases," containing >",z.warning*100,"% zeros/unobserved values ",action," (see arguments z.warning and z.delete).\n",sep="")) } else{ action <- "found" - stop(paste("Column no. ",cases," containing >",z.warning*100,"% zeros/unobserved values ",action," (can modify threshold using argument z.warning. Check out with zPatterns()).\n",sep="")) + stop(paste("Column no. ",cases," containing >",z.warning*100,"% zeros/unobserved values ",action," (see arguments z.warning and z.delete. Check out with zPatterns()).\n",sep="")) } } diff --git a/man/zCompositions-package.Rd b/man/zCompositions-package.Rd index dde290a..a14bb41 100644 --- a/man/zCompositions-package.Rd +++ b/man/zCompositions-package.Rd @@ -11,7 +11,7 @@ Following compositional data analysis principles, this package provides simple a \tabular{ll}{ Package: \tab zCompositions\cr Type: \tab Package\cr -Version: \tab 1.5\cr +Version: \tab 1.5.0-1\cr Date: \tab 2023-12-07\cr License: \tab GPL (>= 2)\cr }