[adegenet-commits] r611 - pkg/R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Tue May 4 14:37:28 CEST 2010


Author: jombart
Date: 2010-05-04 14:37:28 +0200 (Tue, 04 May 2010)
New Revision: 611

Modified:
   pkg/R/loadingplot.R
Log:
Tests on "at" argument; "at" handled differently


Modified: pkg/R/loadingplot.R
===================================================================
--- pkg/R/loadingplot.R	2010-05-04 10:18:30 UTC (rev 610)
+++ pkg/R/loadingplot.R	2010-05-04 12:37:28 UTC (rev 611)
@@ -16,6 +16,11 @@
         warning("Some values in x are less than 0\n Using abs(x) instead, but this might not be optimal.")
         x <- abs(x)
     }
+    if(is.null(at)){
+        at <- 1:length(x)
+    } else {
+        if(length(at) != length(x)) stop("x and at do not have the same length.")
+    }
 
     ## preliminary computations
     y.min <- min(min(x),0)
@@ -49,14 +54,12 @@
     }
 
     ## annotate variables that are above the threshold
-    if(!is.null(at)){
-        x.ann <- at[x > threshold]
-    } else {
-        x.ann <- which(x > threshold)
-    }
+    x.ann <- at[x > threshold]
     x.ann <- jitter(x.ann,fac=lab.jitter)
+
     y.ann <- x[x > threshold] + y.offset
     y.ann <- jitter(y.ann,fac=lab.jitter)
+
     txt.ann <- lab[x > threshold]
     text(x=x.ann, y=y.ann, label=txt.ann, cex=cex.lab)
 



More information about the adegenet-commits mailing list