R Hex to RGB converter

Based on the comments already given, you can use this code:

x <- "#FF2400FF"
paste(as.vector(col2rgb(x)), collapse = " ")
#> [1] "255 36 0"

However, looking at your requested result, it seems that you have the alpha-value as first hex-number in your x – so you need to create a substring:

x <- "#FF2400FF"
paste(as.vector(col2rgb(paste0("#", substr(x, 4, 10)))), collapse = " ")
#> [1] "36 0 255"

Leave a Comment