richelbilderbeek / Cer2016

Community Ecology Research course 2016
GNU General Public License v3.0
1 stars 0 forks source link

Use tidyr::expand to generate nice series #81

Closed richelbilderbeek closed 8 years ago

richelbilderbeek commented 8 years ago

To replace nLTT::get_stretch_matrix

richelbilderbeek commented 8 years ago

Adapted from the documentation:

library(tidyr)
library(dplyr)
df <- data_frame(
  xs = c(0.0, 1.0),
  ys = c(0.2, 0.8)
)
df %>% expand(xs = seq(0.0, 1.0, 0.2), ys)

Results in:

      xs    ys
   (dbl) (dbl)
1    0.0   0.2
2    0.0   0.8
3    0.2   0.2
4    0.2   0.8
5    0.4   0.2
6    0.4   0.8
7    0.6   0.2
8    0.6   0.8
9    0.8   0.2
10   0.8   0.8
11   1.0   0.2
12   1.0   0.8

Conclusion: expand does repetition, instead of interpolation, and is thus unsuitable for this purpose.

richelbilderbeek commented 8 years ago

This issue was moved to richelbilderbeek/nLTT#4