Skip to content

Commit 68a2edf

Browse files
author
maechler
committed
as.matrix.dist(): indices <= s^2
git-svn-id: https://svn.r-project.org/R/trunk@88899 00db46b3-68df-0310-9c12-caf00c1e9a41
1 parent 3addf85 commit 68a2edf

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/library/stats/R/dist.R

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# File src/library/stats/R/dist.R
22
# Part of the R package, https://www.R-project.org
33
#
4-
# Copyright (C) 1995-2024 The R Core Team
4+
# Copyright (C) 1995-2025 The R Core Team
55
#
66
# This program is free software; you can redistribute it and/or modify
77
# it under the terms of the GNU General Public License as published by
@@ -53,8 +53,9 @@ as.matrix.dist <- function(x, ...)
5353
if (size > 1L) {
5454
n..1 <- (size - 1L):1L # n:1
5555
s.1 <- size + 1L
56-
up <- sequence.default(n..1, from = seq.int(s.1, length(df), s.1), by = size)
57-
lo <- sequence.default(n..1, from = seq.int(2L , length(df) + 1L, s.1))
56+
s2 <- size*size
57+
up <- sequence.default(n..1, seq.int(s.1, s2, s.1), by = size)
58+
lo <- sequence.default(n..1, seq.int( 2L, s2, s.1))
5859
df[up] <- df[lo] <- x ## preserving NAs in x
5960
}
6061
labels <- attr(x, "Labels") %||% seq_len(size)

0 commit comments

Comments
 (0)