View source: R/modify_columns.R
cols_move_to_start | R Documentation |
We can easily move set of columns to the beginning of the column series and
we only need to specify which columns
. It's possible to do this upstream of
gt, however, it is easier with this function and it presents less
possibility for error. The ordering of the columns
that are moved to the
start is preserved (same with the ordering of all other columns in the
table).
cols_move_to_start(data, columns)
data |
A table object that is created using the |
columns |
The column names to move to the left-most side of the table. The order in which columns are provided will be preserved (as is the case with the remaining columns). |
The columns supplied in columns
must all exist in the table. If you need to
place one or columns at the end of the column series, the
cols_move_to_end()
function should be used. More control is offered with
the cols_move()
function, where columns could be placed after a specific
column.
An object of class gt_tbl
.
Use countrypops
to create a gt table. With the remaining columns,
move the year
column to the start of the column series with
cols_move_to_start()
.
countrypops |> dplyr::select(-contains("code")) |> dplyr::filter(country_name == "Mongolia") |> tail(5) |> gt() |> cols_move_to_start(columns = year)
Use countrypops
to create a gt table. With the remaining columns,
move year
and population
to the start.
countrypops |> dplyr::select(-contains("code")) |> dplyr::filter(country_name == "Mongolia") |> tail(5) |> gt() |> cols_move_to_start(columns = c(year, population))
5-7
v0.2.0.5
(March 31, 2020)
Other column modification functions:
cols_align_decimal()
,
cols_align()
,
cols_hide()
,
cols_label_with()
,
cols_label()
,
cols_merge_n_pct()
,
cols_merge_range()
,
cols_merge_uncert()
,
cols_merge()
,
cols_move_to_end()
,
cols_move()
,
cols_unhide()
,
cols_width()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.