转换为字符串

基本类型 / 布尔类型

sun_is_star <- TRUE
str_sun <- as.character(sun_is_star)
# str_sun = TRUE

# A string now, not a logical
type <- class(str_sun)
# type = character

earth_is_star <- FALSE
str_earth <- format(earth_is_star)
# str_earth = FALSE

# Inside a sentence
sentence <- paste("Earth is a star:",
                  earth_is_star)
# sentence = Earth is a star: FALSE

cat("str_sun =", str_sun, "\n")
cat("type =", type, "\n")
cat("str_earth =", str_earth, "\n")
cat("sentence =", sentence, "\n")