loop_to_column_conversion: Item Number to Column Row Conversion

View source: R/ReformatLoops.R

loop_to_column_conversionR Documentation

Item Number to Column Row Conversion

Description

Converting from loop to a format that is easy to analyze.

Usage

loop_to_column_conversion(data, name_column, variable_to_convert, type)

Arguments

data

The data containing the loops you need to convert

name_column

The column containing the variable which will eventually column header (see example)

variable_to_convert

What is the variable you would like to link to the name column

type

What is the type of variable you are expecting? "chr" for character, "num" for numeric, "int" for interger, and "fct" for factor.

Details

Rpackage file: ReformatLoops.R

Examples


name_column <- "crop_name"
variable_to_convert <- "crop_variable"
data <- tibble::as_tibble(list(
  crop_name_1 = c("banana", "cassava", NA, "millet"),
  crop_name_2 = c("cassava", NA, "melon", "maize"),
  random_crop_name_2 = c("blue", "green", "red", NA),
  crop_name = c("orange", "purple", NA, "black"),
  crop_variable_1 = c("ex1", "ex2", NA, NA),
  crop_variable_2 = c("ex3", NA, "ex4", "ex5")
))
number_of_loops <- find_number_of_loops(data, name_column)
loop_to_column_conversion(data, name_column, variable_to_convert, type = "chr")

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