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:
4
x <- 5
y <- x + y
z <-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.
4
x <- 5
y <-cat('The sum of x and y is', x+y)
## The sum of x and y is 9