castAllStringsToNA: Cast All Strings to NA

View source: R/utils.R

castAllStringsToNAR Documentation

Cast All Strings to NA

Description

This function processes the columns of a given dataset, converting all non-numeric string values (including factor columns converted to character) to NA. It excludes specified columns from this transformation. Columns that are numeric or of other types are left unchanged.

Usage

castAllStringsToNA(dataset, excludeColumns = c())

Arguments

dataset

A data frame containing the dataset to be processed.

excludeColumns

A character vector specifying the names of columns to be excluded from processing. These columns will not have any values converted to NA.

Details

The function iterates through the specified columns (excluding those listed in excludeColumns), converts factors to character, and then attempts to convert character values to numeric. Any non-numeric strings will be converted to NA. This is useful for cleaning datasets that may contain mixed data types.

Value

A data frame where non-numeric strings in the included columns are replaced with NA, and all other columns remain unchanged.


immunaut documentation built on April 12, 2025, 1:22 a.m.