I have a character
variable with ratios (proportions) expressed as strings:
x <- c("2/3", "5/6", "3/11")
.
I want to convert the character values in x into percentages. Thus, my desired output would be:
c(2/3, 5/6, 3/11) * 100
# [1] 66.66667 83.33333 27.27273
When I try the as.numeric(x)
, a warning message is generated (NAs introduced by coercion) and all elements are converted into NA
What to do?
See Question&Answers more detail:os