name <- "John"
age <- 30
full_name <- paste(name, age)
print(full_name)
## [1] "John 30"
noquote(full_name)
## [1] John 30
formatted_age <- format(age, width = 20, justify = "right",
trim = FALSE)
full_name_and_age <- paste(name, formatted_age, sep = ", ")
print(full_name_and_age)
## [1] "John, 30"
cat("Name and age:", full_name_and_age, "\n")
## Name and age: John, 30
full_name_and_age_string <- toString(full_name_and_age)
print(full_name_and_age_string)
## [1] "John, 30"
formatted_string <- sprintf("My name is %s and I am %d
years old.", name, age)
formatted_string <- paste("My name is", name, " and I am ",age,"years old.")
print(formatted_string)
## [1] "My name is John and I am 30 years old."