Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Impara Print? | Basic Syntax and Operations
TEST R COURSE

Scorri per mostrare il menu

book
Print?

After executing the code, you might notice [1] parts in the output. R is just letting you know that this line begins with the first value in your result. In future sections, you will meet outputs that contain multiple values.

As you remember, there is no need to use a special function to output values in R.

Assume we want to perform a division.

Input:
5/3

Output:
[1] 1.666667

Suppose you want to 'round' the number up to a specific number of digits. In that case, you can use the traditional programming languages function print().

Let's consider the function' structure:

print(expression, digits = n)

For example, we can round the number from the example above to 3 digits.

Input:
print(5/3, digits = 3)

Output:
[1] 1.67

As you can see, the result of the expression was rounded to three digits.

Compito

Swipe to start coding

  1. In the first line, perform a division of 50 by 7.
  2. In the second line, perform a division of 50 by 7, and round the result to 4 digits using the print() function.

Soluzione

Switch to desktopCambia al desktop per esercitarti nel mondo realeContinua da dove ti trovi utilizzando una delle opzioni seguenti
Tutto è chiaro?

Come possiamo migliorarlo?

Grazie per i tuoi commenti!

Sezione 1. Capitolo 2
single

single

Chieda ad AI

expand

Chieda ad AI

ChatGPT

Chieda pure quello che desidera o provi una delle domande suggerite per iniziare la nostra conversazione

close

Awesome!

Completion rate improved to 12.5

book
Print?

After executing the code, you might notice [1] parts in the output. R is just letting you know that this line begins with the first value in your result. In future sections, you will meet outputs that contain multiple values.

As you remember, there is no need to use a special function to output values in R.

Assume we want to perform a division.

Input:
5/3

Output:
[1] 1.666667

Suppose you want to 'round' the number up to a specific number of digits. In that case, you can use the traditional programming languages function print().

Let's consider the function' structure:

print(expression, digits = n)

For example, we can round the number from the example above to 3 digits.

Input:
print(5/3, digits = 3)

Output:
[1] 1.67

As you can see, the result of the expression was rounded to three digits.

Compito

Swipe to start coding

  1. In the first line, perform a division of 50 by 7.
  2. In the second line, perform a division of 50 by 7, and round the result to 4 digits using the print() function.

Soluzione

Switch to desktopCambia al desktop per esercitarti nel mondo realeContinua da dove ti trovi utilizzando una delle opzioni seguenti
Tutto è chiaro?

Come possiamo migliorarlo?

Grazie per i tuoi commenti!

close

Awesome!

Completion rate improved to 12.5

Scorri per mostrare il menu

some-alt