Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Lære print() Function | Section
Practice
Projects
Quizzes & Challenges
Quizzer
Challenges
/
Essential R Programming for Absolute Beginners - 1768563985826

bookprint() Function

When R displays results, the output is often preceded by [1]. This marker indicates that the line begins with the first element of the result. For larger outputs, you will see additional markers such as [2], [3], and so on.

Using print()

Although R automatically shows results, you can use the print() function to control how output is displayed. One of its options is the digits argument, which rounds numbers to a chosen number of significant figures.

print(expression, digits = n)

Example

12
5 / 3 print(5 / 3, digits = 3)
copy

Here, the output of print() is rounded to three significant figures, making results easier to read.

Opgave

Swipe to start coding

  1. On the first line, execute a division of 50 by 7.
  2. On the second line, divide 50 by 7 again, but this time round the result to four significant figures using the print() function.

Løsning

Var alt klart?

Hvordan kan vi forbedre det?

Tak for dine kommentarer!

Sektion 1. Kapitel 3
single

single

Spørg AI

expand

Spørg AI

ChatGPT

Spørg om hvad som helst eller prøv et af de foreslåede spørgsmål for at starte vores chat

close

bookprint() Function

Stryg for at vise menuen

When R displays results, the output is often preceded by [1]. This marker indicates that the line begins with the first element of the result. For larger outputs, you will see additional markers such as [2], [3], and so on.

Using print()

Although R automatically shows results, you can use the print() function to control how output is displayed. One of its options is the digits argument, which rounds numbers to a chosen number of significant figures.

print(expression, digits = n)

Example

12
5 / 3 print(5 / 3, digits = 3)
copy

Here, the output of print() is rounded to three significant figures, making results easier to read.

Opgave

Swipe to start coding

  1. On the first line, execute a division of 50 by 7.
  2. On the second line, divide 50 by 7 again, but this time round the result to four significant figures using the print() function.

Løsning

Switch to desktopSkift til skrivebord for at øve i den virkelige verdenFortsæt der, hvor du er, med en af nedenstående muligheder
Var alt klart?

Hvordan kan vi forbedre det?

Tak for dine kommentarer!

Sektion 1. Kapitel 3
single

single

some-alt