Open In App
Related Articles

Convert a Numeric Object to Character in R Programming – as.character() Function

Improve
Improve
Improve
Like Article
Like
Save Article
Save
Report issue
Report
as.character() function in R Language is used to convert a numeric object to character object.
Syntax: as.character(x) Parameters: x: Numeric Object
Example 1:
# R program to convert a numeric object
# to character object
  
# Calling as.character() function
as.character(1)
as.character(2 + 3)
as.character(1.5)

                    
Output:
[1] "1"
[1] "5"
[1] "1.5"
Example 2:
# R program to convert a numeric object
# to character object
  
# Creating a vector
x1 <- c(1, 2, 3, 4)
x2 <- c(-1, 2, 1.5, -3)
  
# Calling as.character() function
as.character(x1)
as.character(x2)

                    
Output:
[1] "1" "2" "3" "4"
[1] "-1"  "2"   "1.5" "-3" 

Last Updated : 16 Jun, 2020
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads