Skip to content

Commit d82e1d8

Browse files
Merge pull request #31 from m-muecke/any-duplicated
perf: use faster `anyDuplicated(x) > 0` instead of `any(duplicated(x))`
2 parents a8ab2ce + c828891 commit d82e1d8

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

R/hmatrix.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ hmatrix <- function(time, id, x, argvals=1:ncol(x),
8282
x <- matrix(x, ncol=ncol(x), nrow=nrow(x))
8383

8484
#### check argvals and x
85-
if( any(duplicated(argvals)) ){
85+
if(anyDuplicated(argvals) > 0){
8686
stop("argvals contains duplicates.")
8787
}
8888
if( is.unsorted(argvals) ){

R/utilityFunctions.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1178,7 +1178,7 @@ reweightData <- function(data, argvals, vars,
11781178
my_temp_idvars <- temp_idvars
11791179
i <- 1
11801180
## add 0.1^1 to duplicates, 0.1^1 + 0.1^2 = 0.11 to triplicates, ...
1181-
while(any(duplicated(my_index_long))){ # loop until no more duplicates in the data
1181+
while(anyDuplicated(my_index_long) > 0){ # loop until no more duplicates in the data
11821182
my_temp_idvars[duplicated(my_index_long)] <- my_temp_idvars[duplicated(my_index_long)] + 0.1^i
11831183
my_index_long[duplicated(my_index_long)] <- my_index_long[duplicated(my_index_long)] + 0.1^i
11841184
i <- i + 1

0 commit comments

Comments
 (0)