Learn R Programming

sqlcaser (version 0.2.0)

casewhen: Generate a SQL CASE statement from a mapping file

Description

This function constructs a CASE..WHEN,,THEN statement from a mapping file or dataframe. It assumes that the first column of the mapping data contains the original WHEN values, and the second column contains the THEN values (the values to be mapped to.)

Usage

casewhen(inputfile = NULL, header = FALSE)

Value

A string that represents the constructed CASE statement

Arguments

inputfile

Mapping dataframe OR path to the mapping file

header

If reading a csv file, TRUE if the file includes a header row, FALSE if it does not include a header row.

Examples

Run this code
 input <- Data_Frame <- data.frame(Training = c("Strength", "Stamina",
  "Other"), Duration = c(60, 30, 45))
 result <- casewhen(inputfile = input, header = TRUE)

Run the code above in your browser using DataLab