print vs. cat

Published by onesixx on

https://stat.ethz.ch/pipermail/r-help/2004-September/056974.html
https://stackoverflow.com/questions/36699272/why-is-message-a-better-choice-than-print-in-r-for-writing-a-package
https://stackoverflow.com/questions/31843662/what-is-the-difference-between-cat-and-print
what is th diffence among “cat”,”print”and”format”

비슷한 기능의 함수들

  • print()
  • cat()
  • message()
  • warning()
  • stop()
  • alert()

print()

대부분은 print()를 많이 사용하게 될것이다. print(obj, “문장”, quote=F)
cat 과 달리, invisible(x)를 통해 parameter(변수)의 argument(값) 를 return할 수 있다. 
(cat은 NULL을 return한다.)

R
R
wrong

argument를 return할수 있는 기능이 있기 때문에, pipe와 함께 사용하면 유용할 때가 있다.

R

cat()

cat은 기본적인 type(logical, integer, real, complex, character) 을 바로 console에 찍을때 유용하다.
object 따위는 알지못한다.  
cat(“문장”, 오브젝트, 수식, sep=””, paste())

R
http://wolfpack.hannam.ac.kr/Stat_Notes/softwares/software_index.html

print()와 달리

  • 개행(줄바꿈)이 없다.
  • “” 출력 없다.
  • 여러인자를(문자, 숫자..) 구별없이 화면에 잘 찍힌다.
R

foobar.txt 파일 생성

Categories: Reshaping

onesixx

Blog Owner

Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x