add_cols_and_reorder: Add missing columns with names in 'by' not in the column...

View source: R/utilities.R

add_cols_and_reorderR Documentation

Add missing columns with names in 'by' not in the column names of 'tab'. Order the table, ignoring the first column in the order given in the 'by' vector. Optionally, set all NAs to 0s in the data columns only.

Description

Add missing columns with names in 'by' not in the column names of 'tab'. Order the table, ignoring the first column in the order given in the 'by' vector. Optionally, set all NAs to 0s in the data columns only.

Usage

add_cols_and_reorder(tab, by, replace_na = TRUE)

Arguments

tab

data frame with years as the first column, and N columns of data with names

by

a vector of names, which correspond to the names of the columns in tab

replace_na

logical; replace NAs with zeros (default TRUE)

Value

a modified data frame


pbs-assess/herringutils documentation built on Jan. 10, 2025, 8:43 a.m.