目录
cat、print函数都是输出函数。
区别一:
cat()函数不能赋值;
print()函数可以赋值。
x<-cat("hello world") //赋值
hello world
x //cat函数无返回值
NULL
y<-print("hello world")//赋值
[1] "hello world"
y //print函数有返回值
[1] "hello world"
区别二:
cat()函数可以执行转义符,如自动换行。
print()函数直接输出转义符,即原样输出。
> print("hello world\n")
[1] "hello world\n" //直接输出的转义符
> cat("Hello World \n")
Hello World
>