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 Great Tables, however, it is easier with this method 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).
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() method should be used. More control is offered with the cols_move() method, where columns could be placed after a specific column.
Parameters
Name
Type
Description
Default
columns
SelectExpr
The columns to target. Can either be a single column name or a series of column names provided in a list.
The GT object is returned. This is the same object that the method is called on so that we can facilitate method chaining.
Examples
For this example, we’ll use a portion of the countrypops dataset to create a simple table. Let’s move the year column, which is the middle column, to the start of the column series with the cols_move_to_start() method.
We can also move multiple columns at a time. With the same countrypops-based table (countrypops_mini), let’s move both the year and population columns to the start of the column series.