Convert an integer to a string in R

Convert an integer to a string in R

paste0((, min(a), :, max(a), ))
(0:3)

Or more concisely with sprintf():

sprintf((%d:%d), min(a), max(a))

One option is deparse and paste the brackets

as.character(glue::glue(({deparse(a)})))
#[1] (0:3)

Another option would be to store as a quosure and then convert it to character

library(rlang)
a <- quo((0:3))
quo_name(a)
#[1] (0:3)

it can be evaluated with eval_tidy

eval_tidy(a)
#[1] 0 1 2 3

Convert an integer to a string in R

Leave a Reply

Your email address will not be published. Required fields are marked *