Skip to content

Commit e73b48e

Browse files
committed
Fixes Error in names(out) <- c(label, Alig.N)
1 parent 4f014a8 commit e73b48e

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

R/twdtw_reduce_time.R

+7-7
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@
4747
# Match bands and remove bands that are not in both time series
4848
names(py) <- tolower(names(py))
4949
names(px) <- tolower(names(px))
50-
px <- px[,names(py)]
51-
py <- py[,names(px)]
50+
px <- px[,names(py),drop=FALSE]
51+
py <- py[,names(px),drop=FALSE]
5252

5353
# Compute local cost matrix
5454
cm <- proxy::dist(py, px, method = dist.method)
@@ -71,7 +71,7 @@
7171
a <- internals$startingMatrix[internals$N,1:internals$M]
7272
d <- internals$costMatrix[internals$N,1:internals$M]
7373
candidates <- data.frame(a, d)
74-
candidates <- candidates[candidates$d==ave(candidates$d, candidates$a, FUN=min), ]
74+
candidates <- candidates[candidates$d==ave(candidates$d, candidates$a, FUN=min),,drop=FALSE]
7575
candidates$b <- as.numeric(row.names(candidates))
7676

7777
# Order maches by minimum TWDTW distance
@@ -97,7 +97,7 @@
9797
breaks <- seq(as.Date(from), as.Date(to), by = by)
9898
# Find best macthes for the intervals
9999
best_matches <- .bestmatches(
100-
x = list(aligs[order(aligs$from, aligs$from),]),
100+
x = list(aligs[order(aligs$from, aligs$from),,drop=FALSE]),
101101
m = length(y),
102102
n = length(breaks) - 1,
103103
levels = seq_along(y),
@@ -106,13 +106,13 @@
106106
fill = 99999)$IM
107107

108108
# Build output
109-
out <- as.data.frame(best_matches[,c(1,3)])
109+
out <- as.data.frame(best_matches[,c(1,3),drop=FALSE])
110110
names(out) <- c("label", "Alig.N")
111111
out$from <- breaks[-length(breaks)]
112112
out$to <- breaks[-1]
113-
out <- merge(out, aligs[, c("label", "Alig.N", "distance")], by.x = c("label", "Alig.N"), by.y = c("label", "Alig.N"), all.x = TRUE)
113+
out <- merge(out, aligs[, c("label", "Alig.N", "distance"),drop=FALSE], by.x = c("label", "Alig.N"), by.y = c("label", "Alig.N"), all.x = TRUE)
114114
out <- out[order(out$from), names(out)!="Alig.N"]
115-
if(any(out$label==0)) out[out$label==0,]$label <- fill
115+
if(any(out$label==0)) out[out$label==0,,drop=FALSE]$label <- fill
116116
return(out)
117117
}
118118

0 commit comments

Comments
 (0)