Learn R Programming

elasticsearchr (version 0.3.1)

cleaned_field_names: Sanitise column names.

Description

Convert data frame column names into an Elasticsearch compatible format.

Usage

cleaned_field_names(colnames)

Arguments

colnames

A character vector containing data frame column names.

Value

A character vector with 'clean' column names.

Details

Elasticsearch will not ingest field names with periods ("."), such as "Sepal.Width", as these are reserved for nested objects (in the JSON sense). This function replaces all period with underscores ("_") and the converts everything to lowercase for simplicity.

Examples

Run this code
# NOT RUN {
df <- iris
colnames(df) <- cleaned_field_names(colnames(df))
colnames(df)
# "sepal_length" "sepal_width"  "petal_length" "petal_width"  "species"
# }

Run the code above in your browser using DataLab