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 end is preserved (same with the ordering of all other columns in the table).
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 end of the column series with the cols_move_to_end() 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 country_name columns to the end of the column series.