Set The Widths Of Columns — Cols_width • Gt - RStudio
Có thể bạn quan tâm
- Get started
- Reference
- Articles
- Creating Summary Lines
Case studies
- Case Study: gtcars
- Case Study: Clinical Tables
Datasets
- gt Datasets
- More articles...
- News
Releases
- Version 0.11.0
- Version 0.10.0
- Version 0.9.0
- Version 0.8.0
- Version 0.7.0
- Version 0.6.0
- Changelog
-
- Light
- Dark
- Auto
Manual specifications of column widths can be performed using the cols_width() function. We choose which columns get specific widths. This can be in units of pixels (easily set by use of the px() helper function), or, as percentages (where the pct() helper function is useful). Width assignments are supplied in ... through two-sided formulas, where the left-hand side defines the target columns and the right-hand side is a single dimension.
Usage
cols_width(.data, ..., .list = list2(...))Arguments
.dataThe gt table or gt group data object
obj:<gt_tbl> // required
This is the gt table object that is commonly created through use of the gt() function.
OR
obj:<gt_group> // required
This is the gt group object that is commonly created through use of the gt_group() function.
...Column width assignments
<multiple expressions> // required (or, use .list)
Expressions for the assignment of column widths for the table columns in .data. Two-sided formulas (e.g, <LHS> ~ <RHS>) can be used, where the left-hand side corresponds to selections of columns and the right-hand side evaluates to single-length character values in the form {##}px (i.e., pixel dimensions); the px() helper function is best used for this purpose. Column names should be enclosed in c(). The column-based select helpers starts_with(), ends_with(), contains(), matches(), and everything() can be used in the LHS. Subsequent expressions that operate on the columns assigned previously will result in overwriting column width values (both in the same cols_width() call and across separate calls). All other columns can be assigned a default width value by using everything() on the left-hand side.
.listAlternative to ...
<list of multiple expressions> // required (or, use ...)
Allows for the use of a list as an input alternative to ....
Value
An object of class gt_tbl.
Details
Column widths can be set as absolute or relative values (with px and percentage values). Those columns not specified are treated as having variable width. The sizing behavior for column widths depends on the combination of value types, and, whether a table width has been set (which could, itself, be expressed as an absolute or relative value). Widths for the table and its container can be individually modified with the table.width and container.width arguments within tab_options()).
Examples
Use select columns from the exibble dataset to create a gt table. We can specify the widths of columns with cols_width(). This is done with named arguments in ..., specifying the exact widths for table columns (using everything() at the end will capture all remaining columns).
exibble |> dplyr::select( num, char, date, datetime, row ) |> gt() |> cols_width( num ~ px(150), ends_with("r") ~ px(100), starts_with("date") ~ px(200), everything() ~ px(60) )
Function ID
5-3
Function Introduced
v0.2.0.5 (March 31, 2020)
See also
Other column modification functions: cols_add(), cols_align(), cols_align_decimal(), cols_hide(), cols_label(), cols_label_with(), cols_merge(), cols_merge_n_pct(), cols_merge_range(), cols_merge_uncert(), cols_move(), cols_move_to_end(), cols_move_to_start(), cols_nanoplot(), cols_unhide(), cols_units()
On this page
Từ khóa » Html Col Width Px
-
HTML Col Width Attribute
-
CSS Column-width Property - W3Schools
-
Html Table First Column Width Not Respecting Pixel Width - Stack Overflow
-
HTML |
Width Attribute - GeeksforGeeks -
Column-width - CSS: Cascading Style Sheets - MDN Web Docs
-
Mix Column Percentage And Pixels Width Settings In HTML And CSS
-
Chapter 3. How To Specify Tables And Columns Width
-
Making A Wild Card Column Width - Tables
-
How To Set HTML Table Width And Height
-
Stop Using To Set Table Width In HTML: Here's Why »
-
HTML Td Width Attribute - W3Schools
-
DataTable Width & Column Width | Dash For Python Documentation
-
How Column Widths Are Determined In Excel - Office - Microsoft Docs
-
Setting HTML Table And Column Widths - Web