Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
cat() Function
course content

Course Content

R Introduction: Part I

cat() Functioncat() Function

Enhancing the output with descriptive text can greatly improve the readability and user-friendliness of the results. In R, the cat() function serves this exact purpose.

With cat(), you can combine text, expressions, and variables to construct a meaningful output. Each element you want to include in the output should be separated by a comma, and strings of text must be enclosed in quotes. By default, cat() separates each argument with a space. For instance:

This approach clearly enhances the output, providing context and clarity. When you call the cat() function, it prints each message on a new line by default.

Task

Looking back at the task involving the calculation of full days and remaining hours from 435 hours, let's apply what we've learned to improve the output. The format of the output should be:

Remember to utilize integer division (%/%) for the number of whole days and the modulo operator (%%) for any remaining hours.

Everything was clear?

Section 1. Chapter 6
toggle bottom row
some-alt