#R string formatting
x <- 68
y <- 3.14159
#Format a string with the two variable values
result <- sprintf("The answer is %d, and pi is %.2f.", x, y)
print(result)
## [1] "The answer is 68, and pi is 3.14."
#Formating string
cat(sprintf('name: %s\n', 'Mazda3'))
## name: Mazda3
cat(sprintf('make: %s\n', 'Mazda'))
## make: Mazda
cat(sprintf('year: %d\n', 2015))
## year: 2015