Open In App

Write an R Program for “Hello Geeks”

Hello, Geeks is the first basic program in any programming language. Let’s write the program in R programming language. All one needs to do is display the message “Hello World” on the screen. Let’s look at the program:

R Program to Print “Hello Geeks” using the print() function:

The following R program displays “Hello Geeks” in the output.



This code declares a variable containing a message and then prints that message using the “print()” function in R.




# Print "Hello Geeks" message
 
message <-"Hello Geeks"
print(message)

Output

[1] "Hello Geeks"


Printing “Hello Geeks” using cat() function:

The following R program displays “Hello Geeks” in the output.




# Print "Hello Geeks" message
 
message <-"Hello Geeks"
cat(message)

Output:

[1] "Hello Geeks"

R Program to Print “Hello Geeks” using message() function:




message("Hello Geeks")

Output:

Hello Geeks

R Program to Print “Hello Geeks” using the sprintf() function:




name <- "Hello Geeks"
sprintf( name)

Output:

[1] "Hello Geeks"


Article Tags :