Change Data Types Using R

Learn how to convert data types using the pipeline and cut functions in the R programming language.

Change data types in data frames

The dplyr package helps us apply the conversions in data frames without breaking data structures. This lesson shows how we can specifically utilize the mutate() function in data conversions. We can use it to update a column or create new columns. The pipeline function allows us to do it in a puzzle-like structure.

The mutate() function takes two default variables: the variable/column name to be modified and the process. If the variable name already exists, the existing column is updated. Otherwise, a new column is created.

<data> <- mutate(<column> = as.<datatype>(<column>))  # Syntax structure

We update the conc and state ...