OneBite.Dev - Coding blog in a bite size

convert variable from float to string in R

Code snippet on how to convert variable from float to string in R

  x <- 10.4
  x_string <- as.character(x)

This code begins by declaring the float variable “x” with a value of 10.4. Next, the new string variable “x_string” is declared and given the value of “x” converted to a string using the “as.character()” function. This command converts the float value of “x” into a string that can be then used in string operations.

r