cat("Hello world
")
printf("Hello world
")
x <- 1.23
cat(sprintf("x=%.2f
", x))
printf("x=%.2f
", x)
y <- 4.56
cat(sprintf(c("x=%.2f
", "y=%.2f
"), c(x,y)), sep="")
printf(c("x=%.2f
", "y=%.2f
"), c(x,y))
Run the code above in your browser using DataLab