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

tib_id() to create id columns #21

Open
krlmlr opened this issue Oct 2, 2021 · 4 comments
Open

tib_id() to create id columns #21

krlmlr opened this issue Oct 2, 2021 · 4 comments
Labels

Comments

@krlmlr
Copy link
Collaborator

krlmlr commented Oct 2, 2021

Generates a column of type pillar::char(min_width = Inf) .

@mgirlich
Copy link
Owner

Supporting some kind of id columns sounds great to me. But sometimes one also has integer ids. So it might make sense to have something similar for integers. Does pillar also support something like this for integers?

In case you haven't seen it you can also simulate new vectors with lcol_vec():

library(tibblify)

df <- tibblify(
  list(
    list(x = "asdfasdfadsfadsfadsfasdf"),
    list(x = "moinboenoibnoiegbn")
  ),
  lcols(
    lcol_vec(path = "x", ptype = pillar::char("a", min_chars = Inf)),
    x2 = lcol_chr(path = "x")
  )
)

df
#> # A tibble: 2 × 2
#>   x                        x2                      
#>   <char>                   <chr>                   
#> 1 asdfasdfadsfadsfadsfasdf asdfasdfadsfadsfadsfasdf
#> 2 moinboenoibnoiegbn       moinboenoibnoiegbn

dplyr::glimpse(df)
#> Rows: 2
#> Columns: 2
#> $ x  <char> "asdfasdfadsfadsfadsfasdf", "moinboenoibnoiegbn"
#> $ x2 <chr> "asdfasdfadsfadsfadsfasdf", "moinboenoibnoiegbn"

Created on 2021-10-18 by the reprex package (v2.0.1)

@mgirlich mgirlich added the spec label Jun 13, 2022
@mgirlich
Copy link
Owner

@krlmlr pillar also supports some kind of focus columns, right? It might make sense to set tib_id() as focus columns. What do you think?

@mgirlich mgirlich changed the title FR: lcol_id() tib_id() to create id columns Jun 29, 2022
@mgirlich
Copy link
Owner

I think IDs are usually integer (resp. big int) or character. It would make sense to support both, e.g. tib_id(format = c("character", "integer"))

@mgirlich mgirlich added this to the 0.3 milestone Jun 29, 2022
@krlmlr
Copy link
Collaborator Author

krlmlr commented Jun 30, 2022

ID columns are often key columns too. In dm there will be a data structure for tibble-like things with keys, these keys would become focus columns. Would that work for a start?

@mgirlich mgirlich removed this from the 0.3 milestone Dec 2, 2022
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