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

Build columns sequentially in tsibble::tsibble() #289

Open
11rchitwood opened this issue Oct 14, 2022 · 0 comments
Open

Build columns sequentially in tsibble::tsibble() #289

11rchitwood opened this issue Oct 14, 2022 · 0 comments

Comments

@11rchitwood
Copy link

From tibble::tibble()'s documentation:

tibble() builds columns sequentially. When defining a column, you can refer to columns created earlier in the call.

Is it possible to make tsibble() work the same way?

library(tibble)

tibble(
  date = as.Date("2017-01-01") + 0:9,
  value = rnorm(date)
)
#> # A tibble: 10 x 2
#>    date        value
#>    <date>      <dbl>
#>  1 2017-01-01 -0.478
#>  2 2017-01-02  0.894
#>  3 2017-01-03  0.471
#>  4 2017-01-04  1.51 
#>  5 2017-01-05  0.628
#>  6 2017-01-06  1.27 
#>  7 2017-01-07  0.639
#>  8 2017-01-08  0.845
#>  9 2017-01-09 -1.05 
#> 10 2017-01-10 -1.55

library(tsibble)
#> 
#> Attaching package: 'tsibble'
#> The following objects are masked from 'package:base':
#> 
#>     intersect, setdiff, union

tsibble(
  date = as.Date("2017-01-01") + 0:9,
  value = rnorm(date)
)
#> Error in rnorm(date): invalid arguments

Created on 2022-10-14 with reprex v2.0.2

Session info
sessioninfo::session_info()
#> - Session info ---------------------------------------------------------------
#>  setting  value
#>  version  R version 4.1.3 (2022-03-10)
#>  os       Windows 10 x64 (build 19044)
#>  system   x86_64, mingw32
#>  ui       RTerm
#>  language (EN)
#>  collate  English_United States.1252
#>  ctype    English_United States.1252
#>  tz       America/New_York
#>  date     2022-10-14
#>  pandoc   2.18 @ C:\\Users\\07295\\AppData\\Local\\Pandoc/ (via rmarkdown)
#> 
#> - Packages -------------------------------------------------------------------
#>  package     * version date (UTC) lib source
#>  anytime       0.3.9   2020-08-27 [1] CRAN (R 4.1.3)
#>  assertthat    0.2.1   2019-03-21 [1] CRAN (R 4.1.3)
#>  cli           3.3.0   2022-04-25 [1] CRAN (R 4.1.3)
#>  DBI           1.1.3   2022-06-18 [1] CRAN (R 4.1.3)
#>  digest        0.6.29  2021-12-01 [1] CRAN (R 4.1.3)
#>  dplyr         1.0.9   2022-04-28 [1] CRAN (R 4.1.3)
#>  ellipsis      0.3.2   2021-04-29 [1] CRAN (R 4.1.3)
#>  evaluate      0.16    2022-08-09 [1] CRAN (R 4.1.3)
#>  fansi         1.0.3   2022-03-24 [1] CRAN (R 4.1.3)
#>  fastmap       1.1.0   2021-01-25 [1] CRAN (R 4.1.3)
#>  fs            1.5.2   2021-12-08 [1] CRAN (R 4.1.3)
#>  generics      0.1.3   2022-07-05 [1] CRAN (R 4.1.3)
#>  glue          1.6.2   2022-02-24 [1] CRAN (R 4.1.3)
#>  highr         0.9     2021-04-16 [1] CRAN (R 4.1.3)
#>  htmltools     0.5.3   2022-07-18 [1] CRAN (R 4.1.3)
#>  knitr         1.39    2022-04-26 [1] CRAN (R 4.1.3)
#>  lifecycle     1.0.1   2021-09-24 [1] CRAN (R 4.1.3)
#>  lubridate     1.8.0   2021-10-07 [1] CRAN (R 4.1.3)
#>  magrittr      2.0.3   2022-03-30 [1] CRAN (R 4.1.3)
#>  pillar        1.8.1   2022-08-19 [1] CRAN (R 4.1.3)
#>  pkgconfig     2.0.3   2019-09-22 [1] CRAN (R 4.1.3)
#>  purrr         0.3.4   2020-04-17 [1] CRAN (R 4.1.3)
#>  R.cache       0.16.0  2022-07-21 [1] CRAN (R 4.1.3)
#>  R.methodsS3   1.8.2   2022-06-13 [1] CRAN (R 4.1.3)
#>  R.oo          1.25.0  2022-06-12 [1] CRAN (R 4.1.3)
#>  R.utils       2.12.0  2022-06-28 [1] CRAN (R 4.1.3)
#>  R6            2.5.1   2021-08-19 [1] CRAN (R 4.1.3)
#>  Rcpp          1.0.9   2022-07-08 [1] CRAN (R 4.1.3)
#>  reprex        2.0.2   2022-08-17 [1] CRAN (R 4.1.3)
#>  rlang         1.0.4   2022-07-12 [1] CRAN (R 4.1.3)
#>  rmarkdown     2.15    2022-08-16 [1] CRAN (R 4.1.3)
#>  rstudioapi    0.13    2020-11-12 [1] CRAN (R 4.1.3)
#>  sessioninfo   1.2.2   2021-12-06 [1] CRAN (R 4.1.3)
#>  stringi       1.7.6   2021-11-29 [1] CRAN (R 4.1.2)
#>  stringr       1.4.1   2022-08-20 [1] CRAN (R 4.1.3)
#>  styler        1.7.0   2022-03-13 [1] CRAN (R 4.1.3)
#>  tibble      * 3.1.8   2022-07-22 [1] CRAN (R 4.1.3)
#>  tidyselect    1.1.2   2022-02-21 [1] CRAN (R 4.1.3)
#>  tsibble     * 1.1.2   2022-08-21 [1] CRAN (R 4.1.3)
#>  utf8          1.2.2   2021-07-24 [1] CRAN (R 4.1.3)
#>  vctrs         0.4.1   2022-04-13 [1] CRAN (R 4.1.3)
#>  withr         2.5.0   2022-03-03 [1] CRAN (R 4.1.3)
#>  xfun          0.32    2022-08-10 [1] CRAN (R 4.1.3)
#>  yaml          2.3.5   2022-02-21 [1] CRAN (R 4.1.2)
#> 
#>  [1] C:/Users/07295/Documents/R/R-4.1.3/library
#> 
#> ------------------------------------------------------------------------------
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant