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

filter, slice, arrange dropping attributes #1064

Closed
DavisBrian opened this issue Apr 9, 2015 · 9 comments
Closed

filter, slice, arrange dropping attributes #1064

DavisBrian opened this issue Apr 9, 2015 · 9 comments
Assignees
Milestone

Comments

@DavisBrian
Copy link

@DavisBrian DavisBrian commented Apr 9, 2015

I'm not sure if this is by design or a bug.

I would expect that since filter and slice are subsets of the original data frame that all of the original data frames attributes would go along with it. Similarly since arrange is a reordering of the data I would expect it to keep attributes, much like group_by and select do.

library(dplyr)

dat <- as_data_frame(iris)
attr(dat, "meta") <- c("This is important")

# drops meta attributes
dat %>% filter(Species == "setosa") %>% attributes
dat %>% slice(1:50) %>% attributes
dat %>% arrange(Sepal.Width) %>% attributes


# keeps meta attribute
dat %>% group_by(Species) %>% attributes
dat %>% select(Petal.Length, Petal.Width, Species)  %>% attributes
@hadley hadley added this to the 0.4.2 milestone May 19, 2015
@hadley
Copy link
Member

@hadley hadley commented May 19, 2015

@romainfrancois can we also preserve all data frame attributes?

@DavisBrian do you expect summarise() to keep attributes too?

@DavisBrian
Copy link
Author

@DavisBrian DavisBrian commented May 19, 2015

@hadley I would not expect summarise() to keep attributes. In my mind summarise() represents different data. The other functions are more or less just subsets and orderings of the same data. Or at least that's my use case.

@hadley hadley added this to the 0.5 milestone May 21, 2015
@hadley hadley removed this from the 0.4.2 milestone May 21, 2015
@eamcvey
Copy link

@eamcvey eamcvey commented Jun 9, 2015

In my experience, this issue often creates problems using lubridate and dplyr together, which is a thing I'm always wanting to do!

@hadley
Copy link
Member

@hadley hadley commented Jun 9, 2015

Should be fixed the dev version

@hadley hadley closed this Jun 9, 2015
@hadley
Copy link
Member

@hadley hadley commented Jun 9, 2015

Oops, wrong issue.

@hadley hadley reopened this Jun 9, 2015
@romainfrancois romainfrancois self-assigned this Aug 14, 2015
@romainfrancois
Copy link
Member

@romainfrancois romainfrancois commented Aug 14, 2015

Ah. Might have closed it too soon. So @hadley do we want to keep attributes for summarise too ?

@hadley
Copy link
Member

@hadley hadley commented Aug 14, 2015

Hmmmmmmmm, for summarise I think we should be able to rely on the summary function doing the right thing. (So that might require preserving attributes in the hybrid handlers)

@romainfrancois
Copy link
Member

@romainfrancois romainfrancois commented Aug 14, 2015

Sure, but this only concerns attributes of the columns right ?
This is more about some meta attributes of the data frame itself, should they be propagated to the resulting data frame.
Or perhaps I did not understand you.

@hadley
Copy link
Member

@hadley hadley commented Aug 14, 2015

Oh, sorry yes :/ So summarise should preserve these attributes.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants