Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

function
r
communitycreator

What is the message() function in R?

Onyejiaku Theophilus Chidalu

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

Overview

R’s message() function generates diagnostic messages that are not errors or warnings.

Syntax

message(…, domain = NULL, appendLF = TRUE)
Syntax for the message() function in R

Parameter value

The message() function takes the following parameter values:

  • ...: This is a form of string(s) that is to be pasted together with no separator. This is a required parameter.
  • domain: This represents the domain for the translation. This is an optional parameter.
  • appendLF: This takes a logical value indicating whether the messages given as a character string should have a newline appended or not. This is an optional parameter.

Example

# Code to illustrate the message() function
message("Thirty four")
message("Apple", "Banana", "Pineapple")
Implementing the message() function

Explanation

  • Line 2: We use the message() function to return the character string passed to it as an argument.
  • Line 3: We use the message() function to return string characters pasted together with no separator.

Why use the message() function?

The message() function is better than the paste() function when we want to concatenate strings, as it is shorter to write.

Example

message("a", "b", "c")
print(paste0("a", "b", "C"))
Comparing both functions

Explanation

Line 1–2: We compare the message() and the paste() function.

RELATED TAGS

function
r
communitycreator

CONTRIBUTOR

Onyejiaku Theophilus Chidalu

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

Keep Exploring