Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
/gtPublic

Allow for easy insertion of ggplot plots in a table column via a formatter#155

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
rich-iannone wants to merge13 commits intomaster
base:master
Choose a base branch
Loading
fromfmt_ggplot

Conversation

@rich-iannone
Copy link
Member

@rich-iannonerich-iannone commentedJan 31, 2019
edited
Loading

The newfmt_ggplot() function allows for easier inclusion ofggplot2 plots (within a list column of the input table data) into agt table. The common pattern toward obtaining these plots is through
mutation of a list column containing all thedata required for plot:

<data> %>%dplyr::group_by(<var>) %>%tidyr::nest(.key=plot) %>%dplyr::mutate(plot=purrr::map(plot,<ggplotcode>))

While the PR contains functionality to detect and automatically format columns containingggplot2 plots, we can also opt to use thefmt_ggplot() function to allow us to specifyrows and set options for the plots'height andaspect_ratio.

Here are some examples of how this would work:

# Create a small table with a `plot` columngtcars_plot_column<-gtcars %>%dplyr::group_by(mfr) %>%tidyr::nest(.key=plot) %>%dplyr::mutate(plot= map(plot,~ggplot(., aes(hp,trq))+ geom_point())) %>%  head(3)# Automatic formatting of plots in `plot` using# default optionstab_1<-gtcars_plot_column %>%  gt()# Using `fmt_ggplot()` to provide values# for `columns`, `height` and `aspect_ratio`tab_2<-gtcars_plot_column %>%  gt() %>%  fmt_ggplot(columns= vars(plot),height=200,aspect_ratio=2.5  )

Here are images oftab_1 andtab_2:

tab_1

tab_2

These are minimal examples showing the basic usage of inserting plots, so, the resulting tables look less than ideal. With some extra care given to setting common axis ranges and usingggplot2::theme() to increase font sizes, line widths, etc., inserted plots would become more aesthetically pleasing.

Fixes#152

@rich-iannonerich-iannone changed the titleAllow for easy insertion of ggplot plots in a table column via a formatter[WIP] Allow for easy insertion of ggplot plots in a table column via a formatterFeb 10, 2019
Copy link
Member

@jcheng5jcheng5 left a comment

Choose a reason for hiding this comment

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

As discussed in person, I think all such features shouldn't be specific to ggplot but should work with all static R plots.

* master: (37 commits)  Use webshot to generate images of HTML tables (#257)  Rewritten vignette for adding summary rows (#273)  Move roxygen documentation to Markdown (#253)  Store empty-string value in `sep` vector (#274)  Bugfixes and improvements to `summary_rows()` (#175)  Modify _travis.yml (#263)  Make several refactoring improvements to some `format_*()` functions (#244)  Include option to hide all column labels (#237)  Refactoring of formatter functions (#232)  Improvement to the handling of a `pattern` in most `fmt*()` functions (#95)  pkgdown cleanup (#226)  Make argument names in `tab_options()` more consistent with terminology (#221)  dplyr::data_frame deprecated (#195)  Remove a unicode character from roxygen documentation (#220)  Try again, this time with `travis encrypt --com`  Trying again with github token (#223)  Use jcheng5 GitHub PAT instead of rich-iannone (#222)  Update README (#219)  Fix for `fmt_date()` that allows `Date` columns to work (#203)  Remove check on macOS  ...
@rich-iannonerich-iannone mentioned this pull requestJul 2, 2019
@GregSutcliffe
Copy link

@rich-iannone any update on this? embedded plots came up again for me today, and I'm getting by with a rebased version of this branch... can I help at all?

@ciallen
Copy link

Hey! Any updates to this? I need to embed box plots in a table and would love to use this function. Thanks!

@ymer
Copy link

It would be nice if this could be pushed. I think 90%+ of the use would be for ggplot, and it works well for that.

@rich-iannonerich-iannone changed the title[WIP] Allow for easy insertion of ggplot plots in a table column via a formatterAllow for easy insertion of ggplot plots in a table column via a formatterNov 17, 2022
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

1 more reviewer

@jcheng5jcheng5jcheng5 requested changes

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

addingggplot graphs in every row of a table

6 participants

@rich-iannone@GregSutcliffe@ciallen@ymer@jcheng5

[8]ページ先頭

©2009-2025 Movatter.jp