Does anyone know how to do the convert numeric value into string value in R?
For example:
c(1,2,3,4)
into
c("Region 1", "Region 2", "Region 3", "Region 4")
Does anyone know how to do the convert numeric value into string value in R?
For example:
c(1,2,3,4)
into
c("Region 1", "Region 2", "Region 3", "Region 4")
You use the commands as.character
and paste
In your case, something like this would work
x <- c(1:4)
x <- as.character(x)
x <- paste("Region", x)
print(x)
[1] "Region 1" "Region 2" "Region 3" "Region 4"
Although I think R overloads its functions sufficiently so that this would work without first converting x
to a character, as noted by the comment above. I included the as.character
bit because the OP asked "does anyone know how to do the convert numeric value into string value in R".