Open jeff-goldsmith opened 2 years ago
you can get running medians or averages from tf_smooth
, and then only keep the arg-vals you care about.
EDIT: but in that version, we do need a function to put the tf
-object on a different domain measured in different units --> tidyfun/tf#6....
library(tidyfun)
#> Registered S3 method overwritten by 'GGally':
#> method from
#> +.gg ggplot2
#>
#> Attaching package: 'tidyfun'
#> The following objects are masked from 'package:stats':
#>
#> sd, var
library(tidyverse)
hour_data <- chf_df %>% filter(day == "Mon") |>
select(id, activity) |>
tf_unnest(activity) %>%
mutate(hour = floor((activity_arg -1) / 60)) %>%
group_by(id, hour) %>%
summarize(act_hour = mean(activity_value)) %>%
tf_nest(.id = id, .arg = hour)
#> `summarise()` has grouped output by 'id'. You can override using the `.groups`
#> argument.
hour_data2 <- chf_df %>% filter(day == "Mon") |>
select(id, activity) |>
mutate(act_hour2 =
tf_smooth(activity, method = "rollmean", k = 60, align = "right") |>
tfd(arg = seq(60, 1440, by = 60))) |>
select(-activity)
#> setting fill = 'extend' for start/end values.
ggplot(hour_data) + geom_spaghetti(aes(y = act_hour))
ggplot(hour_data2) + geom_spaghetti(aes(y = act_hour2))
Created on 2022-04-26 by the reprex package (v2.0.1)
makes sense! if this turns out to be a common operation, we could introduce something to handle this directly -- or at least update a vignette somewhere.
strange lil update on this: if you unnest and re-nest the result of this binning process, you can plot the created tf
object but can't print it.
library(tidyfun)
#> Registered S3 method overwritten by 'GGally':
#> method from
#> +.gg ggplot2
#>
#> Attaching package: 'tidyfun'
#> The following objects are masked from 'package:stats':
#>
#> sd, var
library(tidyverse)
hour_data2 <-
chf_df %>%
filter(day == "Mon") |>
select(id, activity) |>
mutate(act_hour =
tf_smooth(activity, method = "rollmean", k = 60, align = "right") |>
tfd(arg = seq(60, 1440, by = 60))) |>
select(-activity) %>%
tf_unnest(act_hour) %>%
tf_nest(act_hour_value, .id = id, .arg = act_hour_arg)
#> setting fill = 'extend' for start/end values.
ggplot(hour_data2) + geom_spaghetti(aes(y = act_hour_value))
hour_data2
#> Error in prettyNum(.Internal(format(x, trim, digits, nsmall, width, 3L, : invalid value 0 for 'digits' argument
Created on 2022-05-31 by the reprex package (v2.0.1)
if you use tfd(arg = seq(1, 1440, by = 1))
, everything seems to work ...
guessing the issue is inside print-format.R
but don't have a handle on what's going on.
can't reproduce this with tidyfun@42cb5d8 (latest commit in dev) -- what package versions are you using?
library(tidyfun)
#> Registered S3 method overwritten by 'GGally':
#> method from
#> +.gg ggplot2
#>
#> Attaching package: 'tidyfun'
#> The following objects are masked from 'package:stats':
#>
#> sd, var
library(tidyverse)
hour_data2 <-
chf_df %>%
filter(day == "Mon") |>
select(id, activity) |>
mutate(act_hour =
tf_smooth(activity, method = "rollmean", k = 60, align = "right") |>
tfd(arg = seq(60, 1440, by = 60))) |>
select(-activity) %>%
tf_unnest(act_hour) %>%
tf_nest(act_hour_value, .id = id, .arg = act_hour_arg)
#> setting fill = 'extend' for start/end values.
ggplot(hour_data2) + geom_spaghetti(aes(y = act_hour_value))
hour_data2
#> # A tibble: 47 × 2
#> id act_hour_value
#> <dbl> <tfd_reg>
#> 1 1 [1]: ( 60,0);(120,1);(180,0); ...
#> 2 3 [2]: ( 60,6);(120,5);(180,4); ...
#> 3 4 [3]: ( 60,2);(120,2);(180,1); ...
#> 4 5 [4]: ( 60,6);(120,6);(180,5); ...
#> 5 6 [5]: ( 60,1);(120,0);(180,1); ...
#> 6 7 [6]: ( 60,1);(120,1);(180,1); ...
#> 7 8 [7]: ( 60,0);(120,0);(180,0); ...
#> 8 9 [8]: ( 60,0);(120,1);(180,0); ...
#> 9 10 [9]: ( 60,1);(120,1);(180,1); ...
#> 10 11 [10]: ( 60,1);(120,1);(180,1); ...
#> # … with 37 more rows
> sessioninfo::session_info()
─ Session info ─────────────────────────────────────────────────────────────────────
setting value
version R version 4.1.0 (2021-05-18)
os Linux Mint 20
system x86_64, linux-gnu
ui RStudio
language en_US
collate en_US.UTF-8
ctype en_US.UTF-8
tz Europe/Berlin
date 2022-06-01
rstudio 1.4.1717 Juliet Rose (desktop)
pandoc 2.11.4 @ /usr/lib/rstudio/bin/pandoc/ (via rmarkdown)
─ Packages ─────────────────────────────────────────────────────────────────────────
! package * version date (UTC) lib source
abind 1.4-5 2016-07-21 [1] CRAN (R 4.1.0)
assertthat 0.2.1 2019-03-21 [1] CRAN (R 4.1.0)
backports 1.4.1 2021-12-13 [1] CRAN (R 4.1.0)
bitops 1.0-7 2021-04-24 [1] CRAN (R 4.1.0)
boot 1.3-28 2021-05-03 [1] CRAN (R 4.1.0)
brio 1.1.3 2021-11-30 [1] CRAN (R 4.1.0)
broom 0.8.0 2022-04-13 [1] CRAN (R 4.1.0)
bslib 0.3.1 2021-10-06 [1] CRAN (R 4.1.0)
cachem 1.0.6 2021-08-19 [1] CRAN (R 4.1.0)
callr 3.7.0 2021-04-20 [1] CRAN (R 4.1.0)
cellranger 1.1.0 2016-07-27 [1] CRAN (R 4.1.0)
checkmate 2.1.0 2022-04-21 [1] CRAN (R 4.1.0)
cli 3.3.0 2022-04-25 [1] CRAN (R 4.1.0)
clipr 0.8.0 2022-02-22 [1] CRAN (R 4.1.0)
cluster 2.1.2 2021-04-17 [1] CRAN (R 4.1.0)
colorspace 2.0-3 2022-02-21 [1] CRAN (R 4.1.0)
crayon 1.5.1 2022-03-26 [1] CRAN (R 4.1.0)
DBI 1.1.2 2021-12-20 [1] CRAN (R 4.1.0)
dbplyr 2.1.1 2021-04-06 [1] CRAN (R 4.1.0)
desc 1.4.1 2022-03-06 [1] CRAN (R 4.1.0)
deSolve 1.32 2022-04-14 [1] CRAN (R 4.1.0)
devtools 2.4.3 2021-11-30 [1] CRAN (R 4.1.0)
digest 0.6.29 2021-12-01 [1] CRAN (R 4.1.0)
dplyr * 1.0.9 2022-04-28 [1] CRAN (R 4.1.0)
ellipsis 0.3.2 2021-04-29 [1] CRAN (R 4.1.0)
evaluate 0.15 2022-02-18 [1] CRAN (R 4.1.0)
fansi 1.0.3 2022-03-24 [1] CRAN (R 4.1.0)
farver 2.1.0 2021-02-28 [1] CRAN (R 4.1.0)
fastmap 1.1.0 2021-01-25 [1] CRAN (R 4.1.0)
fda 6.0.3 2022-04-26 [1] CRAN (R 4.1.0)
fds 1.8 2018-10-31 [1] CRAN (R 4.1.0)
forcats * 0.5.1 2021-01-27 [1] CRAN (R 4.1.0)
fs 1.5.2 2021-12-08 [1] CRAN (R 4.1.0)
gamm4 0.2-6 2020-04-03 [1] CRAN (R 4.1.0)
generics 0.1.2 2022-01-31 [1] CRAN (R 4.1.0)
GGally 2.1.2 2021-06-21 [1] CRAN (R 4.1.0)
ggplot2 * 3.3.6 2022-05-03 [1] CRAN (R 4.1.0)
glue 1.6.2 2022-02-24 [1] CRAN (R 4.1.0)
grpreg 3.4.0 2021-07-26 [1] CRAN (R 4.1.0)
gtable 0.3.0 2019-03-25 [1] CRAN (R 4.1.0)
haven 2.5.0 2022-04-15 [1] CRAN (R 4.1.0)
hdrcde 3.4 2021-01-18 [1] CRAN (R 4.1.0)
highr 0.9 2021-04-16 [1] CRAN (R 4.1.0)
hms 1.1.1 2021-09-26 [1] CRAN (R 4.1.0)
htmltools 0.5.2 2021-08-25 [1] CRAN (R 4.1.0)
httpuv 1.6.5 2022-01-05 [1] CRAN (R 4.1.0)
httr 1.4.3 2022-05-04 [1] CRAN (R 4.1.0)
jquerylib 0.1.4 2021-04-26 [1] CRAN (R 4.1.0)
jsonlite 1.8.0 2022-02-22 [1] CRAN (R 4.1.0)
KernSmooth 2.23-20 2021-05-03 [1] CRAN (R 4.1.0)
knitr 1.39 2022-04-26 [1] CRAN (R 4.1.0)
ks 1.13.5 2022-04-14 [1] CRAN (R 4.1.0)
labeling 0.4.2 2020-10-20 [1] CRAN (R 4.1.0)
later 1.3.0 2021-08-18 [1] CRAN (R 4.1.0)
lattice 0.20-45 2021-09-22 [1] CRAN (R 4.1.0)
lifecycle 1.0.1 2021-09-24 [1] CRAN (R 4.1.0)
lme4 1.1-29 2022-04-07 [1] CRAN (R 4.1.0)
lubridate 1.8.0 2021-10-07 [1] CRAN (R 4.1.0)
magic 1.6-0 2022-02-09 [1] CRAN (R 4.1.0)
magrittr 2.0.3 2022-03-30 [1] CRAN (R 4.1.0)
MASS 7.3-55 2022-01-13 [1] CRAN (R 4.1.0)
Matrix 1.4-0 2021-12-08 [1] CRAN (R 4.1.0)
mclust 5.4.9 2021-12-17 [1] CRAN (R 4.1.0)
memoise 2.0.1 2021-11-26 [1] CRAN (R 4.1.0)
mgcv 1.8-39 2022-02-24 [1] CRAN (R 4.1.0)
mime 0.12 2021-09-28 [1] CRAN (R 4.1.0)
miniUI 0.1.1.1 2018-05-18 [1] CRAN (R 4.1.0)
minqa 1.2.4 2014-10-09 [1] CRAN (R 4.1.0)
modelr 0.1.8 2020-05-19 [1] CRAN (R 4.1.0)
munsell 0.5.0 2018-06-12 [1] CRAN (R 4.1.0)
mvtnorm 1.1-3 2021-10-08 [1] CRAN (R 4.1.0)
nlme 3.1-155 2022-01-13 [1] CRAN (R 4.1.0)
nloptr 2.0.1 2022-05-03 [1] CRAN (R 4.1.0)
pbs 1.1 2013-06-08 [1] CRAN (R 4.1.0)
pcaPP 2.0-1 2022-04-26 [1] CRAN (R 4.1.0)
pillar 1.7.0 2022-02-01 [1] CRAN (R 4.1.0)
pkgbuild 1.3.1 2021-12-20 [1] CRAN (R 4.1.0)
pkgconfig 2.0.3 2019-09-22 [1] CRAN (R 4.1.0)
pkgload 1.2.4 2021-11-30 [1] CRAN (R 4.1.0)
plyr 1.8.7 2022-03-24 [1] CRAN (R 4.1.0)
pracma 2.3.8 2022-03-04 [1] CRAN (R 4.1.0)
prettyunits 1.1.1 2020-01-24 [1] CRAN (R 4.1.0)
processx 3.5.3 2022-03-25 [1] CRAN (R 4.1.0)
promises 1.2.0.1 2021-02-11 [1] CRAN (R 4.1.0)
ps 1.7.0 2022-04-23 [1] CRAN (R 4.1.0)
purrr * 0.3.4 2020-04-17 [1] CRAN (R 4.1.0)
R.cache 0.15.0 2021-04-30 [1] CRAN (R 4.1.0)
R.methodsS3 1.8.1 2020-08-26 [1] CRAN (R 4.1.0)
R.oo 1.24.0 2020-08-26 [1] CRAN (R 4.1.0)
R.utils 2.11.0 2021-09-26 [1] CRAN (R 4.1.0)
R6 2.5.1 2021-08-19 [1] CRAN (R 4.1.0)
rainbow 3.6 2019-01-29 [1] CRAN (R 4.1.0)
RColorBrewer 1.1-3 2022-04-03 [1] CRAN (R 4.1.0)
Rcpp 1.0.8.3 2022-03-17 [1] CRAN (R 4.1.0)
RCurl 1.98-1.6 2022-02-08 [1] CRAN (R 4.1.0)
readr * 2.1.2 2022-01-30 [1] CRAN (R 4.1.0)
readxl 1.4.0 2022-03-28 [1] CRAN (R 4.1.0)
refund 0.1-26 2022-04-16 [1] CRAN (R 4.1.0)
remotes 2.4.2 2021-11-30 [1] CRAN (R 4.1.0)
reprex 2.0.1 2021-08-05 [1] CRAN (R 4.1.0)
reshape 0.8.9 2022-04-12 [1] CRAN (R 4.1.0)
rlang 1.0.2 2022-03-04 [1] CRAN (R 4.1.0)
RLRsim 3.1-8 2022-03-16 [1] CRAN (R 4.1.0)
rmarkdown 2.14 2022-04-25 [1] CRAN (R 4.1.0)
rprojroot 2.0.3 2022-04-02 [1] CRAN (R 4.1.0)
rstudioapi 0.13 2020-11-12 [1] CRAN (R 4.1.0)
rvest 1.0.2 2021-10-16 [1] CRAN (R 4.1.0)
sass 0.4.1 2022-03-23 [1] CRAN (R 4.1.0)
scales 1.2.0 2022-04-13 [1] CRAN (R 4.1.0)
sessioninfo 1.2.2 2021-12-06 [1] CRAN (R 4.1.0)
shiny * 1.7.1 2021-10-02 [1] CRAN (R 4.1.0)
stringi 1.7.6 2021-11-29 [1] CRAN (R 4.1.0)
stringr * 1.4.0 2019-02-10 [1] CRAN (R 4.1.0)
styler 1.7.0 2022-03-13 [1] CRAN (R 4.1.0)
testthat * 3.1.4 2022-04-26 [1] CRAN (R 4.1.0)
tibble * 3.1.7 2022-05-03 [1] CRAN (R 4.1.0)
P tidyfun * 0.0.96 2022-05-10 [?] Github (tidyfun/tidyfun@42cb5d8)
tidyr * 1.2.0 2022-02-01 [1] CRAN (R 4.1.0)
tidyselect 1.1.2 2022-02-21 [1] CRAN (R 4.1.0)
tidyverse * 1.3.1 2021-04-15 [1] CRAN (R 4.1.0)
tzdb 0.3.0 2022-03-28 [1] CRAN (R 4.1.0)
usethis 2.1.5 2021-12-09 [1] CRAN (R 4.1.0)
utf8 1.2.2 2021-07-24 [1] CRAN (R 4.1.0)
vctrs 0.4.1 2022-04-13 [1] CRAN (R 4.1.0)
withr 2.5.0 2022-03-03 [1] CRAN (R 4.1.0)
xfun 0.30 2022-03-02 [1] CRAN (R 4.1.0)
xml2 1.3.3 2021-11-30 [1] CRAN (R 4.1.0)
xtable 1.8-4 2019-04-21 [1] CRAN (R 4.1.0)
yaml 2.3.5 2022-02-21 [1] CRAN (R 4.1.0)
zoo 1.8-10 2022-04-15 [1] CRAN (R 4.1.0)
[1] /home/fabians/R/x86_64-pc-linux-gnu-library/4.1
[2] /usr/local/lib/R/site-library
[3] /usr/lib/R/site-library
[4] /usr/lib/R/library
P ── Loaded and on-disk path mismatch.
definitely a package version issue -- i upgraded to R 4.2.0 on the machine where it breaks, and also can't reproduce the issue elsewhere.
library(tidyverse)
hour_data2 <-
chf_df %>%
filter(day == "Mon") |>
select(id, activity) |>
mutate(act_hour =
tf_smooth(activity, method = "rollmean", k = 60, align = "right") |>
tfd(arg = seq(60, 1440, by = 60))) |>
select(-activity) %>%
tf_unnest(act_hour) %>%
tf_nest(act_hour_value, .id = id, .arg = act_hour_arg)
#> Error in tf_nest(., act_hour_value, .id = id, .arg = act_hour_arg): could not find function "tf_nest"
ggplot(hour_data2) + geom_spaghetti(aes(y = act_hour_value))
#> Error in ggplot(hour_data2): object 'hour_data2' not found
sessioninfo::session_info()
#> ─ Session info ───────────────────────────────────────────────────────────────
#> setting value
#> version R version 4.2.0 (2022-04-22)
#> os macOS Big Sur/Monterey 10.16
#> system x86_64, darwin17.0
#> ui X11
#> language (EN)
#> collate en_US.UTF-8
#> ctype en_US.UTF-8
#> tz America/New_York
#> date 2022-06-01
#> pandoc 2.17.1.1 @ /Applications/RStudio.app/Contents/MacOS/quarto/bin/ (via rmarkdown)
#>
#> ─ Packages ───────────────────────────────────────────────────────────────────
#> package * version date (UTC) lib source
#> assertthat 0.2.1 2019-03-21 [2] CRAN (R 4.2.0)
#> backports 1.4.1 2021-12-13 [2] CRAN (R 4.2.0)
#> broom 0.8.0 2022-04-13 [2] CRAN (R 4.2.0)
#> cellranger 1.1.0 2016-07-27 [2] CRAN (R 4.2.0)
#> cli 3.3.0 2022-04-25 [2] CRAN (R 4.2.0)
#> colorspace 2.0-3 2022-02-21 [2] CRAN (R 4.2.0)
#> crayon 1.5.1 2022-03-26 [2] CRAN (R 4.2.0)
#> DBI 1.1.2 2021-12-20 [2] CRAN (R 4.2.0)
#> dbplyr 2.1.1 2021-04-06 [2] CRAN (R 4.2.0)
#> digest 0.6.29 2021-12-01 [2] CRAN (R 4.2.0)
#> dplyr * 1.0.9 2022-04-28 [2] CRAN (R 4.2.0)
#> ellipsis 0.3.2 2021-04-29 [2] CRAN (R 4.2.0)
#> evaluate 0.15 2022-02-18 [2] CRAN (R 4.2.0)
#> fansi 1.0.3 2022-03-24 [2] CRAN (R 4.2.0)
#> fastmap 1.1.0 2021-01-25 [2] CRAN (R 4.2.0)
#> forcats * 0.5.1 2021-01-27 [2] CRAN (R 4.2.0)
#> fs 1.5.2 2021-12-08 [2] CRAN (R 4.2.0)
#> generics 0.1.2 2022-01-31 [2] CRAN (R 4.2.0)
#> ggplot2 * 3.3.6 2022-05-03 [2] CRAN (R 4.2.0)
#> glue 1.6.2 2022-02-24 [2] CRAN (R 4.2.0)
#> gtable 0.3.0 2019-03-25 [2] CRAN (R 4.2.0)
#> haven 2.5.0 2022-04-15 [2] CRAN (R 4.2.0)
#> highr 0.9 2021-04-16 [2] CRAN (R 4.2.0)
#> hms 1.1.1 2021-09-26 [2] CRAN (R 4.2.0)
#> htmltools 0.5.2 2021-08-25 [2] CRAN (R 4.2.0)
#> httr 1.4.3 2022-05-04 [2] CRAN (R 4.2.0)
#> jsonlite 1.8.0 2022-02-22 [2] CRAN (R 4.2.0)
#> knitr 1.39 2022-04-26 [2] CRAN (R 4.2.0)
#> lifecycle 1.0.1 2021-09-24 [2] CRAN (R 4.2.0)
#> lubridate 1.8.0 2021-10-07 [2] CRAN (R 4.2.0)
#> magrittr 2.0.3 2022-03-30 [2] CRAN (R 4.2.0)
#> modelr 0.1.8 2020-05-19 [2] CRAN (R 4.2.0)
#> munsell 0.5.0 2018-06-12 [2] CRAN (R 4.2.0)
#> pillar 1.7.0 2022-02-01 [2] CRAN (R 4.2.0)
#> pkgconfig 2.0.3 2019-09-22 [2] CRAN (R 4.2.0)
#> purrr * 0.3.4 2020-04-17 [2] CRAN (R 4.2.0)
#> R6 2.5.1 2021-08-19 [2] CRAN (R 4.2.0)
#> readr * 2.1.2 2022-01-30 [2] CRAN (R 4.2.0)
#> readxl 1.4.0 2022-03-28 [2] CRAN (R 4.2.0)
#> reprex 2.0.1 2021-08-05 [2] CRAN (R 4.2.0)
#> rlang 1.0.2 2022-03-04 [2] CRAN (R 4.2.0)
#> rmarkdown 2.14 2022-04-25 [2] CRAN (R 4.2.0)
#> rstudioapi 0.13 2020-11-12 [2] CRAN (R 4.2.0)
#> rvest 1.0.2 2021-10-16 [2] CRAN (R 4.2.0)
#> scales 1.2.0 2022-04-13 [2] CRAN (R 4.2.0)
#> sessioninfo 1.2.2 2021-12-06 [2] CRAN (R 4.2.0)
#> stringi 1.7.6 2021-11-29 [2] CRAN (R 4.2.0)
#> stringr * 1.4.0 2019-02-10 [2] CRAN (R 4.2.0)
#> tibble * 3.1.7 2022-05-03 [2] CRAN (R 4.2.0)
#> tidyr * 1.2.0 2022-02-01 [2] CRAN (R 4.2.0)
#> tidyselect 1.1.2 2022-02-21 [2] CRAN (R 4.2.0)
#> tidyverse * 1.3.1 2021-04-15 [2] CRAN (R 4.2.0)
#> tzdb 0.3.0 2022-03-28 [2] CRAN (R 4.2.0)
#> utf8 1.2.2 2021-07-24 [2] CRAN (R 4.2.0)
#> vctrs 0.4.1 2022-04-13 [2] CRAN (R 4.2.0)
#> withr 2.5.0 2022-03-03 [2] CRAN (R 4.2.0)
#> xfun 0.31 2022-05-10 [2] CRAN (R 4.2.0)
#> xml2 1.3.3 2021-11-30 [2] CRAN (R 4.2.0)
#> yaml 2.3.5 2022-02-21 [2] CRAN (R 4.2.0)
#>
#> [1] /Users/jeffgoldsmith/Library/R/x86_64/4.2/library
#> [2] /Library/Frameworks/R.framework/Versions/4.2/Resources/library
#>
#> ──────────────────────────────────────────────────────────────────────────────
Created on 2022-06-01 by the reprex package (v2.0.1)
definitely a package version issue
those are my FAVORITES :-1:
makes sense! if this turns out to be a common operation, we could introduce something to handle this directly -- or at least update a vignette somewhere.
do this
i've added getter/setter functions that let you do this now -- @jeff-goldsmith is this roughly what you would want here or do we need a more convenient way to do this?
> library(tidyverse)
> act <- tidyfun::chf_df |> pull(activity)
> act_hour <- tf_smooth(act, method = "rollmean", k = 60, align = "right") |>
+ tfd(arg = seq(60, 1440, by = 60))
setting fill = 'extend' for start/end values.
> tf_domain(act_hour) <- tf_domain(act_hour)/60
Warning message:
In `tf_domain<-`(`*tmp*`, value = c(1, 24)) :
This changes the functions' domain but not the argument values!
To restrict functions to a part of their domain, use tf_zoom.
> tf_arg(act_hour) <- tf_arg(act_hour)/60
Warning message:
In `tf_arg<-`(`*tmp*`, value = c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, :
This changes arguments (and resolution) without changing the corresponding function values!
In order to re-evaluate functions on a new grid, use tf_interpolate.
> act_hour
tfd[329] on (1,24) based on 24 evaluations each
interpolation by tf_approx_linear
[1]: (1,0.4);(2,1.2);(3,0.3); ...
I think this helps! The downsampling is primarily done through tf_smooth()
but having finer control over domain
and arg
through these functions will help here and in a lot of other settings.
if you have functions measured over a rich grid, you might want to downsample (e.g. go from minute-level wearable device data to 5 minute or one-hour increments). if that's your goal, you might prefer to average over bins -- but i don't think there's a good way to do that right now, is there?
tf_evaluate
lets you evaluate on a new domain, but uses interpolation rather than averaging. andtf_integrate
could work, sort of, in that you get average value betweenlower
andupper
-- but it produces a scalar, and you'd have to do some kind of loop.for what it's worth, my current work around is to unnest, aggregate, then nest and re-merge. something like: