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

Useful functions for DSR and ISR functions #21

Open
sebastian-fox opened this issue Apr 10, 2019 · 0 comments
Open

Useful functions for DSR and ISR functions #21

sebastian-fox opened this issue Apr 10, 2019 · 0 comments
Labels
enhancement New feature or request

Comments

@sebastian-fox
Copy link
Contributor

I've just been pointed towards two tidyr functions that might be useful for the two functions named above (comlpete, and expand). From their documentation:

library(dplyr, warn.conflicts = FALSE)
library(tidyr)
df <- tibble(
  group = c(1:2, 1),
  item_id = c(1:2, 2),
  item_name = c("a", "b", "b"),
  value1 = 1:3,
  value2 = 4:6
)
df %>% complete(group, nesting(item_id, item_name))

df <- tibble(
  year   = c(2010, 2010, 2010, 2010, 2012, 2012, 2012),
  qtr    = c(   1,    2,    3,    4,    1,    2,    3),
  return = rnorm(7)
)
df %>% expand(year, qtr)

Just thought I'd document it in case you found them useful

@GeorgieAnderson GeorgieAnderson added the enhancement New feature or request label Jun 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants