Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

join operations between tsibbles with mutual key and index #102

Closed
mitchelloharawild opened this issue Mar 8, 2019 · 1 comment
Closed
Labels

Comments

@mitchelloharawild
Copy link
Member

mitchelloharawild commented Mar 8, 2019

library(tsibble)
#> 
#> Attaching package: 'tsibble'
#> The following objects are masked from 'package:stats':
#> 
#>     filter, lag
dt_new <- tsibble(Time = 0:23, rnorm = rnorm(24), Sensor = "???", index = Time)
pedestrian %>% 
  left_join(dt_new, by = "Time")
#> Error in .f(.x[[i]], ...): object 'Sensor' not found

Created on 2019-03-08 by the reprex package (v0.2.1)

Issue is because the join operation renames the key. Perhaps a tsibble join operation should protect the names of keys from the LHS and only make new names for the RHS dataset.

library(tsibble)
#> 
#> Attaching package: 'tsibble'
#> The following objects are masked from 'package:stats':
#> 
#>     filter, lag
dt_new <- tsibble(Time = 0:23, rnorm = rnorm(24), Sensor = "???", index = Time)
pedestrian %>% 
  as_tibble %>% 
  left_join(dt_new, by = "Time")
#> # A tibble: 66,037 x 7
#>    Sensor.x     Date_Time           Date        Time Count   rnorm Sensor.y
#>    <chr>        <dttm>              <date>     <int> <int>   <dbl> <chr>   
#>  1 Birrarung M… 2015-01-01 00:00:00 2015-01-01     0  1630 -1.67   ???     
#>  2 Birrarung M… 2015-01-01 01:00:00 2015-01-01     1   826  0.0206 ???     
#>  3 Birrarung M… 2015-01-01 02:00:00 2015-01-01     2   567  0.0870 ???     
#>  4 Birrarung M… 2015-01-01 03:00:00 2015-01-01     3   264  0.720  ???     
#>  5 Birrarung M… 2015-01-01 04:00:00 2015-01-01     4   139 -1.64   ???     
#>  6 Birrarung M… 2015-01-01 05:00:00 2015-01-01     5    77 -0.640  ???     
#>  7 Birrarung M… 2015-01-01 06:00:00 2015-01-01     6    44 -0.830  ???     
#>  8 Birrarung M… 2015-01-01 07:00:00 2015-01-01     7    56 -0.603  ???     
#>  9 Birrarung M… 2015-01-01 08:00:00 2015-01-01     8   113 -1.34   ???     
#> 10 Birrarung M… 2015-01-01 09:00:00 2015-01-01     9   166  0.0506 ???     
#> # … with 66,027 more rows

Created on 2019-03-08 by the reprex package (v0.2.1)

mitchelloharawild added a commit to tidyverts/fabletools that referenced this issue Mar 8, 2019
@earowang
Copy link
Member

earowang commented Mar 8, 2019

Index too.

library(tsibble)
#> 
#> Attaching package: 'tsibble'
#> The following objects are masked from 'package:stats':
#> 
#>     filter, lag
dt_new <- tsibble(Date_Time = pedestrian$Date_Time[1:24], Time = 0:23, rnorm = rnorm(24), Sensor = "???", index = Date_Time)
pedestrian %>%
  left_join(dt_new, by = c("Sensor"))
#> Error in eval_tidy(enquo(var), var_env): object 'Date_Time' not found

Created on 2019-03-08 by the reprex package (v0.2.1)

@earowang earowang changed the title join operations between tsibbles with mutual key by non-key variable looks for key join operations between tsibbles with mutual key and index Mar 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants