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

column name leak/conflict? #715

Closed
espinielli opened this issue Feb 17, 2021 · 2 comments · Fixed by #772
Closed

column name leak/conflict? #715

espinielli opened this issue Feb 17, 2021 · 2 comments · Fixed by #772

Comments

@espinielli
Copy link

cols_label fails when you have a column named d.
Without a call to cols_label it works.
Using another column name it works too.

library(tibble)
library(gt)

# this WORKS
# tribble(
#   ~a , ~e ,
#   1, 4,
#   5, 8
# ) %>% 
#   gt() %>% 
#   cols_label(
#     a = "label a",
#     e = "label e"
#   )

tribble(
  ~a , ~d ,
  1, 4,
  5, 8
) %>% 
  gt() %>% 
  cols_label(
    a = "label a",
    d = "label d"
  )
#> Error: The object to `data` is not a `gt_tbl` object.

Created on 2021-02-17 by the reprex package (v1.0.0)

@KaiAragaki
Copy link

KaiAragaki commented Apr 3, 2021

This appears to be some kind of partial matching with a 'data' argument.

library(tibble)
library(gt)
# Fails
tribble(
  ~a , ~dat ,
  1, 4,
  5, 8
) %>% 
  gt() %>% 
  cols_label(
    a = "label a",
    dat = "label d"
  )
#> Error: The object to `data` is not a `gt_tbl` object.

# Fails
tribble(
  ~a , ~data ,
  1, 4,
  5, 8
) %>% 
  gt() %>% 
  cols_label(
    a = "label a",
    dat = "label d"
  )
#> Error: The object to `data` is not a `gt_tbl` object.


# Works
tribble(
  ~a , ~datr ,
  1, 4,
  5, 8
) %>% 
  gt() %>% 
  cols_label(
    a = "label a",
    datr = "label d"
  )

# Works
tribble(
  ~a , ~datas ,
  1, 4,
  5, 8
) %>% 
  gt() %>% 
  cols_label(
    a = "label a",
    datas = "label d"
  )

Created on 2021-04-02 by the reprex package (v1.0.0)

@rich-iannone
Copy link
Member

Thanks for posting this issue @espinielli and thanks @KaiAragaki for finding the root cause. What needs to happen is to change the data arg to .data and avoid most cases of this. There are likely other things that could be done in addition to this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment