Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Apprendre Variables | Section
Essential R Programming for Absolute Beginners - 1768563985826

bookVariables

Note
Definition

A variable is a named location in memory that holds a value. The name can then be used to access or modify that value.

Variables are essential in R because they allow you to store values for later use, making code easier to write, read, and maintain.

Naming Rules

  • A variable name can include letters, numbers, dots(.), and underscores(_);
  • A variable name can only start with a letter or a dot;
  • If a variable name starts with a dot, the next character can't be a number;
  • A variable name cannot be the same as a reserved keyword, such as TRUE, FALSE, NA, etc.
Note
Note

Choose meaningful names that describe the data. For example, year is more descriptive than a. This improves code readability.

Assignment Syntax

To assign a value to a variable, the assignment operator = can be used.

Example

12
year = 2020 cat(year)
copy
Tâche

Swipe to start coding

You want to prepare values for a deposit calculation. Save the following data into variables:

  • 2000 as initial_money;
  • 13 as interest_rate;
  • 4 as n_years.

Then, use cat() to display these values together in the same order.

Solution

Tout était clair ?

Comment pouvons-nous l'améliorer ?

Merci pour vos commentaires !

Section 1. Chapitre 8
single

single

Demandez à l'IA

expand

Demandez à l'IA

ChatGPT

Posez n'importe quelle question ou essayez l'une des questions suggérées pour commencer notre discussion

close

bookVariables

Glissez pour afficher le menu

Note
Definition

A variable is a named location in memory that holds a value. The name can then be used to access or modify that value.

Variables are essential in R because they allow you to store values for later use, making code easier to write, read, and maintain.

Naming Rules

  • A variable name can include letters, numbers, dots(.), and underscores(_);
  • A variable name can only start with a letter or a dot;
  • If a variable name starts with a dot, the next character can't be a number;
  • A variable name cannot be the same as a reserved keyword, such as TRUE, FALSE, NA, etc.
Note
Note

Choose meaningful names that describe the data. For example, year is more descriptive than a. This improves code readability.

Assignment Syntax

To assign a value to a variable, the assignment operator = can be used.

Example

12
year = 2020 cat(year)
copy
Tâche

Swipe to start coding

You want to prepare values for a deposit calculation. Save the following data into variables:

  • 2000 as initial_money;
  • 13 as interest_rate;
  • 4 as n_years.

Then, use cat() to display these values together in the same order.

Solution

Switch to desktopPassez à un bureau pour une pratique réelleContinuez d'où vous êtes en utilisant l'une des options ci-dessous
Tout était clair ?

Comment pouvons-nous l'améliorer ?

Merci pour vos commentaires !

Section 1. Chapitre 8
single

single

some-alt