More work on resample.R to check Javascript calcs