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

Is there a way to set tibble as the global option of R data.frame? #716

Closed
hope-data-science opened this issue Feb 7, 2020 · 6 comments
Closed
Milestone

Comments

@hope-data-science
Copy link

tibble is perhaps the best data.frame structure I've seen for a data.frame, is there a way to set it as the default way to display the data.frame in the global environent, so it could be used for dispaly automatically?

@jennybc
Copy link
Member

jennybc commented Feb 18, 2020

There's not and there's unlikely to be. Changing any default behaviour for data frame is very fraught. So if you like tibble printing (and perhaps other tibble behaviour) then I think it means you really need to make an active effort to work with tibbles.

@hope-data-science
Copy link
Author

Thank you for the response. We should never change the behavior, but the printing format could be changed. Tibble is the safest way for showing a data.frame. I have figured out a way, inspired by a folk. For your reference: https://hope-data-science.github.io/tidyfst/articles/example5_tibble.html. Here I acutally want to show the data.table in the tibble format.

@jennybc
Copy link
Member

jennybc commented Feb 24, 2020

It's generally not a good idea to create or modify a method for which you don't "own" either the generic (print()) or the class (data.table). So this is something you can do on a very small scale, i.e. for personal use or within an .Rmd document, but I don't think it would be appreciated in a package, for example.

First, you should only ever write a method if you own the generic or the class. R will allow you to define a method even if you don’t, but it is exceedingly bad manners. Instead, work with the author of either the generic or the class to add the method in their code. *from Advanced R

@hope-data-science
Copy link
Author

hope-data-science commented Feb 26, 2020

I do hope data.table could provide a data type in the headers, I'll try when possible. Moreover, I'll consider removing tibble as the import as you noted, but currently it might be a useful way for end-users and my function acutually create an option for users by overwriting the default printing method of data.table, but not doing it invisibly without noting. If many users are uncomfortable with that, I'll remove the function show_tibble and the import of tibble in the next release (and keep it as a trick but not guidance in the package).

Thanks.

@hope-data-science
Copy link
Author

I do find an option to find the column class of data.table, which is options("datatable.print.class" = TRUE). I'll remove this inappropriate feature in the next release.

Thanks.

@krlmlr krlmlr closed this as completed Mar 6, 2020
@krlmlr krlmlr added this to the 3.0.0 milestone Mar 21, 2020
@github-actions
Copy link
Contributor

This old thread has been automatically locked. If you think you have found something related to this, please open a new issue and link to this old issue if necessary.

@github-actions github-actions bot locked and limited conversation to collaborators Mar 23, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants