summaryrefslogtreecommitdiff
path: root/R
diff options
context:
space:
mode:
Diffstat (limited to 'R')
-rw-r--r--R/rsc.R13
1 files changed, 8 insertions, 5 deletions
diff --git a/R/rsc.R b/R/rsc.R
index b46ae84..025ec0b 100644
--- a/R/rsc.R
+++ b/R/rsc.R
@@ -39,19 +39,22 @@ rsc <- function(cv, threshold = "minimum", weights = NULL){
}
}
+ # make a copy
+ rmadvec <- cv$rmadvec
+
## threshold the rmadvec
if(is.null(weights)){
- cv$rmadvec[ abs(cv$rmadvec) < threshold ] <- 0
+ rmadvec[ abs(rmadvec) < threshold ] <- 0
}else{
- T <- abs(cv$rmadvec) * weights
- cv$rmadvec[ T < threshold ] <- 0
+ T <- abs(rmadvec) * weights
+ rmadvec[ T < threshold ] <- 0
}
- nc <- length(cv$rmadvec)
+ nc <- length(rmadvec)
p <- {1 + sqrt( 1 + 8 * nc ) } / 2
R <- Matrix(1, nrow = p, ncol = p, sparse = TRUE)
- R[lower.tri(R , diag = FALSE)] <- cv$rmadvec
+ R[lower.tri(R , diag = FALSE)] <- rmadvec
R <- forceSymmetric(R , uplo="L")
## attach dimnames if needed