LTTB algorithm for downsampling time series (R implementation)