Skip to content

set domain to union when concatenating? #1

@jeff-goldsmith

Description

@jeff-goldsmith

building on #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:

  • is an error here better than a warning?
  • what's the preferred workaround? changing the arg in tfd ...?
  • should we allow direct editing of the domain through tf_domain() <-?

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions