tidyfun / tf

S3 classes and methods for tidy functional data
https://tidyfun.github.io/tf/
GNU Affero General Public License v3.0
5 stars 2 forks source link

set domain to union when concatenating? #1

Open jeff-goldsmith opened 2 years ago

jeff-goldsmith commented 2 years ago

building on tidyfun/tf#2, although the behavior might show up elsewhere.

after downsampling, the original and downsampled data have different domains; if you wanted to concatenate these in a single vector, you'd get an error:

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)
#> Warning: package 'tidyr' was built under R version 4.0.5
#> Warning: package 'dplyr' was built under R version 4.0.5

data(chf_df)

chf_hour_df = 
  chf_df %>% 
  filter(day == "Mon") %>% 
  select(id, activity) %>% 
  mutate(
    act_hour = tf_smooth(activity, method = "rollmean", k = 60, align = "right"),
    act_hour = tfd(act_hour, arg = seq(60, 1440, by = 60)))  %>% 
  select(-activity) 
#> setting fill = 'extend' for start/end values.

c(chf_df$activity[1], chf_hour_df$act_hour[1])
#> Error in vec_ptype2_tfd_tfd(x, y, ...): all(compatible[, "domain"]) is not TRUE

Created on 2022-05-09 by the reprex package (v0.3.0)

this is the intended behavior, and the use case is maybe not that compelling -- it's not exactly this example, but being able to show full and downsampled data on the same plot would be helpful.

a few questions:

fabian-s commented 2 years ago

option 3, ad more informative error message