Skip to content

Commit dce94d2

Browse files
author
hornik
committed
Try to avoid integer overflow reported in PR#18951.
git-svn-id: https://svn.r-project.org/R/trunk@88949 00db46b3-68df-0310-9c12-caf00c1e9a41
1 parent 646808e commit dce94d2

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/library/base/R/interaction.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ interaction <- function(..., drop = FALSE, sep = ".", lex.order = FALSE)
3939
nx <- length(lx)
4040
ny <- length(ly)
4141
if(lex.order) {
42-
ay <- ay + ny * ax
42+
ay <- ay + as.numeric(ny) * ax
4343
if(drop) {
4444
az <- sort(unique(ay))
4545
ly <- paste(lx[az %/% ny + 1L], ly[az %% ny + 1L],
@@ -50,7 +50,7 @@ interaction <- function(..., drop = FALSE, sep = ".", lex.order = FALSE)
5050
sep = sep)
5151
}
5252
} else {
53-
ay <- ay * nx + ax
53+
ay <- ay * as.numeric(nx) + ax
5454
if(drop) {
5555
az <- sort(unique(ay))
5656
ly <- paste(lx[az %% nx + 1L], ly[az %/% nx + 1L],

0 commit comments

Comments
 (0)