[R] cat() and print()

An essential difference between cat and print is the class of the object they return. This difference has practical consequences for what you can do with the returned object.

print returns a character vector:

> print(paste("a", 100* 1:3))

 "a 100" "a 200" "a 300"

> class(print(paste("a", 100* 1:3)))

"a 100" "a 200" "a 300"

 "character"

cat returns an object of class NULL:

> cat(paste("a", 100* 1:3))

a 100 a 200 a 300

> class(cat(paste("a", 100* 1:3)))

a 100 a 200 a 300

"NULL"

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 回忆之前,我总要打开朝南的窗子 把今夜的梦晒在春天里,挑拣 闭着眼也能抚摸的笑颜 你让我总是活在昨天,青春的昨天 ...
    泰安左眼皮跳跳阅读 264评论 0 10
  • 不同性别的消费者,即使是消费同一样的产品,也会有着不同的选择情况。男人相对来说可能会“粗枝大叶”一点,而女性则柔和...
    简单lsw阅读 504评论 0 0