js scaling timeseries in R