Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Learn cat() Function | Syntax and Basic Operations
R Introduction

bookcat() Function

The cat() function in R allows you to combine text, numbers, and expressions into a single formatted output. This makes results easier to interpret by adding context alongside values.

Syntax

Each element is separated by a comma, and text strings must be enclosed in quotes. By default, cat() separates arguments with a space.

Example

12
cat("The result of integer division is", 10 %/% 3) cat("The remainder of the division is", 10 %% 3)
copy

When you call the cat() function, it prints each message on a new line by default.

Task

Swipe to start coding

Reflecting on the task of calculating full days and remaining hours from 435 hours, let's enhance the output format. The output should be structured as follows:

Full days: number
Remaining hours: number

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

Solution

Everything was clear?

How can we improve it?

Thanks for your feedback!

SectionΒ 1. ChapterΒ 7
single

single

Ask AI

expand

Ask AI

ChatGPT

Ask anything or try one of the suggested questions to begin our chat

close

Awesome!

Completion rate improved to 2.27

bookcat() Function

Swipe to show menu

The cat() function in R allows you to combine text, numbers, and expressions into a single formatted output. This makes results easier to interpret by adding context alongside values.

Syntax

Each element is separated by a comma, and text strings must be enclosed in quotes. By default, cat() separates arguments with a space.

Example

12
cat("The result of integer division is", 10 %/% 3) cat("The remainder of the division is", 10 %% 3)
copy

When you call the cat() function, it prints each message on a new line by default.

Task

Swipe to start coding

Reflecting on the task of calculating full days and remaining hours from 435 hours, let's enhance the output format. The output should be structured as follows:

Full days: number
Remaining hours: number

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

Solution

Switch to desktopSwitch to desktop for real-world practiceContinue from where you are using one of the options below
Everything was clear?

How can we improve it?

Thanks for your feedback!

close

Awesome!

Completion rate improved to 2.27
SectionΒ 1. ChapterΒ 7
single

single

some-alt