~javiljoen/LTTB.R#1: 
Cannot downsample to ≥ half the number of points

When trying to downsample a matrix with n rows to any value ≥ 0.5 n, the following error is returned:

Error in apply(data[floor(i * bin_width + 1:bin_width), ], 2, mean) : 
  dim(X) must have a positive length

Steps to reproduce:

n = 20
data = data.frame(X=seq_len(n), Y=rnorm(n))
LTTB(data, n_bins=n/2)  # Error
LTTB(data, n_bins=n/2 - 1)  # Works fine

[Imported from https://github.com/javiljoen/LTTB/issues/2]

Status
REPORTED
Submitter
~javiljoen
Assigned to
No-one
Submitted
2 years ago
Updated
2 years ago
Labels
No labels applied.

~javiljoen 2 years ago*

Here is a function for correctly splitting the data into bins (similar to numpy.array_split):

https://stackoverflow.com/a/45206984/4145144

Register here or Log in to comment, or comment via email.