Feature Transformation -- StringIndexer

Encode a column of labels into a column of label indices. The indices are in [0, numLabels), ordered by label frequencies, with the most frequent label assigned index 0. The transformation can be reversed with ft_index_to_string.

ft_string_indexer(x, input.col, output.col, params = NULL, ...)



An object (usually a spark_tbl) coercable to a Spark DataFrame.


The name of the input column(s).


The name of the output column.


An (optional) R environment -- when available, the index <-> label mapping generated by the string indexer will be injected into this environment under the labels key.


Optional arguments; currently unused.

See also

See http://spark.apache.org/docs/latest/ml-features for more information on the set of transformations available for DataFrame columns in Spark.

Other feature transformation routines: ft_binarizer, ft_bucketizer, ft_count_vectorizer, ft_discrete_cosine_transform, ft_elementwise_product, ft_index_to_string, ft_one_hot_encoder, ft_quantile_discretizer, ft_regex_tokenizer, ft_stop_words_remover, ft_tokenizer, ft_vector_assembler, sdf_mutate