modify_loop_column_names: Modify Loop Names

View source: R/CleanColumnNames.R

modify_loop_column_namesR Documentation

Modify Loop Names

Description

A function to modify column names for RHoMIS loops

Usage

modify_loop_column_names(column_names, loop_type)

Arguments

column_names

A list of the column names which need to be shortened. This would generally be all of the column names of the RHoMIS dataset.

loop_type

What loop_type of loop is concerned, this could include options such as "crop_repeat", "livestock_repeat", "offfarm_income_repeat". It is very important that this "type" matches the pattern in the original column names

Details

The RHoMIS survey is structured using a series of important loops. These are often labelled: "xxxx/crop_repeat[1]/crop_name", "xxxx/crop_repeat[2]/crop_name", "xxxx/crop_repeat[3]/crop_name"...

This function aims to modify those into a more user-friendly format: "crop_name_1", "crop_name_2", "crop_name_3" ...

Rpackage file: CleanColumnNames.R

Value

A list of column names which need to be modified

Examples

original_columns <- c(
  "x/non_repeat_column",
  "xxxx/crop_repeat[1]/crop_name",
  "xxxx/crop_repeat[2]/crop_name"
)
loop_type <- "crop_repeat"

modified_names <- modify_loop_column_names(original_columns, loop_type)

l-gorman/rhomis-R-package documentation built on Nov. 8, 2023, 6:46 a.m.