diff --git a/R/computeDiffInCounts.R b/R/computeDiffInCounts.R index c8abbfa..10a3beb 100644 --- a/R/computeDiffInCounts.R +++ b/R/computeDiffInCounts.R @@ -4,20 +4,14 @@ computeDiffInCounts <- function(rows, max_noalle, nloci, data) { # % riveill� rows. rows pit�� olla vaakavektori. diffInCounts <- zeros(max_noalle, nloci) - for (i in seq_len(nrow(data))) { + for (i in rows) { # yep, just one iteration row <- data[i, ] notEmpty <- as.matrix(matlab2r::find(row >= 0)) if (length(notEmpty) > 0) { - diffInCounts[row(notEmpty) + (notEmpty - 1) * max_noalle] <- - diffInCounts[row(notEmpty) + (notEmpty - 1) * max_noalle] + 1 + element <- row[notEmpty] + (notEmpty - 1) * max_noalle + diffInCounts[element] <- diffInCounts[element] + 1 } } - diffInCounts <- matrix( - data = diffInCounts[!is.na(diffInCounts)], - nrow = max_noalle, - ncol = nloci, - byrow = TRUE - ) return(diffInCounts) }