1.7 Hello World

To print an output, simply use the function print()

print('Hello Word!')
## [1] "Hello Word!"

Sometimes we would also want to display the value of a variable:

x <- 4
y <- 5
z <- x+y
print(z)
## [1] 9

However, we want to print the description of the variable too. Then we have to use function cat() to combine description and output.

x <- 4
y <- 5
cat('The sum of x and y is', x+y)
## The sum of x and y is 9