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

add 'frame_data() (#804) #1358

Merged
merged 2 commits into from Aug 27, 2015
Merged

add 'frame_data() (#804) #1358

merged 2 commits into from Aug 27, 2015

Conversation

@kevinushey
Copy link
Contributor

@kevinushey kevinushey commented Aug 27, 2015

This PR implements the proposed

frame_data(
    ~colA, ~colB,
    "a", 1,
    "b", 2
)

as a means of constructing data_frame. tibble is also included as an alias, because it's too awesome a name not to use.

@kevinushey kevinushey mentioned this pull request Aug 27, 2015
@kevinushey kevinushey force-pushed the feature/frame_data branch from 20b1551 to 727978b Aug 27, 2015
@hadley
Copy link
Member

@hadley hadley commented Aug 27, 2015

Nice! Could you please add a bullet to NEWS?

Loading

@kevinushey
Copy link
Contributor Author

@kevinushey kevinushey commented Aug 27, 2015

Just as you posted ;)

Loading

hadley added a commit that referenced this issue Aug 27, 2015
@hadley hadley merged commit 2e6cbaf into tidyverse:master Aug 27, 2015
1 check was pending
Loading
@hadley
Copy link
Member

@hadley hadley commented Aug 27, 2015

Thanks!

Loading

@krlmlr
Copy link
Member

@krlmlr krlmlr commented Sep 1, 2015

Constructing tables with more than two rows doesn't work for me (1405946):

tbl <- dplyr::tibble(
  ~a, ~b,
  "1", 1,
  "1", 2,
  "2", 1)

tbl
## Source: local data frame [2 x 2]
## 
##       a     b
##   (chr) (chr)
## 1     1     1
## 2     2     2
tbl <- dplyr::tibble(
  ~a, ~b,
  "1", 1,
  "1", 2,
  "2", 2,
  "2", 1)

tbl
## Source: local data frame [2 x 2]
## 
##       a     b
##   (chr) (dbl)
## 1     1     1
## 2     2     2
tbl <- dplyr::tibble(
  ~a, ~b, ~Freq,
  1, 1, 5,
  1, 2, 6,
  2, 2, 7,
  2, 1, 8)

tbl
## Source: local data frame [3 x 3]
## 
##       a     b  Freq
##   (dbl) (dbl) (dbl)
## 1     1     1     5
## 2     2     6     2
## 3     7     2     1

I have a failing test case in a branch.

Loading

@kevinushey
Copy link
Contributor Author

@kevinushey kevinushey commented Sep 1, 2015

Thanks @krlmlr -- I have a PR up that should fix this. #1377

Hopefully we can get this in before the dplyr submission...

Loading

robertzk
Copy link
Contributor

robertzk commented on 727978b Sep 14, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is vulnerable to issues like:

> frame_data(~A, ~B)
Error in dots[[i]] : subscript out of bounds

which results in a rather undescriptive error. I would suggest something closer to

> dots <- list(1, 2)
> i <- 3
> dots[-seq_len(i - 1)]
list()
> dots <- list(1,2,3)
> dots[-seq_len(i - 1)]
[[1]]
[1] 3

Loading

kevinushey
Copy link
Contributor

kevinushey commented on 727978b Sep 14, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you be willing to submit a PR making the required change + adding a unit test?

Loading

robertzk
Copy link
Contributor

robertzk commented on 727978b Sep 14, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will try to by end of today!

Loading

@klmr
Copy link

@klmr klmr commented Sep 23, 2015

This needs better documentation. I’ve just read the above examples and the code and I still had no idea what this function actually does. Only once I read the fix in #1377 did it click.

Loading

krlmlr pushed a commit to krlmlr/dplyr that referenced this issue Mar 2, 2016
@lock
Copy link

@lock lock bot commented Jan 19, 2019

This old issue has been automatically locked. If you believe you have found a related problem, please file a new issue (with reprex) and link to this issue. https://reprex.tidyverse.org/

Loading

@lock lock bot locked and limited conversation to collaborators Jan 19, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

5 participants