先看代码:
# display
cat("Powers of", x, "\n")
cat("exponent result\n\n")
result <- 1
for (i in 1:5) {
result <- result * 7
cat(format(i, width = 8),
format(result, width = 10),
"\n",
sep = "")
# sep为预设的间隔符,paste类似于拼接字符串
}
cat("\n")
cat(paste(format(1:5, width = 8), format(7^(1:5), width = 9),
"\n"), sep = "")
输出结果
Show in New WindowClear OutputExpand/Collapse Output
Powers of 7
exponent result
1 7
2 49
3 343
4 2401
5 16807
1 7
2 49
3 343
4 2401
5 16807
前后两部分设置设置的第二个width不同,但是在 输出结果 来看,是 一模一样 的,请问有何区别?为什么会出现这样的结果?