Introduction à R - Gestion de données
24 Questions
0 Views

Choose a study mode

Play Quiz
Study Flashcards
Spaced Repetition
Chat to Lesson

Podcast

Play an AI-generated podcast conversation about this lesson

Questions and Answers

Quelle fonction est utilisée pour supprimer tous les objets de l'espace de travail R?

  • save()
  • setwd()
  • ls()
  • rm() (correct)

La fonction mean() peut être utilisée pour calculer la moyenne d'un vecteur sans tenir compte des valeurs NA par défaut.

False (B)

Quelle est la commande pour voir les types d'objets dans R?

class()

Pour importer un dataframe à partir d'un fichier texte, on utilise la fonction ______.

<p>read.table()</p> Signup and view all the answers

Associez les types d'objets avec leur description :

<p>vector = Une séquence de valeurs de même type matrix = Un tableau à deux dimensions data.frame = Une structure de données tabulaire list = Une collection d'objets divers</p> Signup and view all the answers

Comment calcule-t-on l'âge de découverte des chercheurs dans le dataframe nobel?

<p>nobel$year_research_mid - nobel$year_birth (D)</p> Signup and view all the answers

La commande 'save.image' est utilisée pour enregistrer l'espace de travail actuel dans un fichier.

<p>True (A)</p> Signup and view all the answers

Comment supprime-t-on les lignes contenant des valeurs manquantes (NA) dans un dataframe?

<p>subset(nobel, subset=!is.na(duree))</p> Signup and view all the answers

What does the function 'setwd()' do in R?

<p>It sets the working directory to a specified path. (D)</p> Signup and view all the answers

The command 'mean(y, na.rm = TRUE)' calculates the mean of y while ignoring NA values.

<p>True (A)</p> Signup and view all the answers

Which function would you use to load a previously saved workspace in R?

<p>load</p> Signup and view all the answers

To create a vector in R, you use the function _______.

<p>c</p> Signup and view all the answers

What does the command 'rm(list=ls(all=TRUE))' accomplish?

<p>It removes all objects from the global environment. (A)</p> Signup and view all the answers

How can you calculate the average age of high creativity in the Nobel dataset?

<p>mean(nobel$age_discovery)</p> Signup and view all the answers

Match the following R commands with their purposes:

<p>head(nobel) = Displays the first few rows of a dataframe tail(nobel) = Displays the last few rows of a dataframe dim(nobel) = Shows the dimensions of the dataframe colnames(nobel) = Retrieves column names of the dataframe</p> Signup and view all the answers

The lifespan of researchers in the Nobel dataset can be calculated by subtracting the year of birth from the year of ______.

<p>death</p> Signup and view all the answers

What is the purpose of the command 'getwd()' in R?

<p>To retrieve the current working directory (B)</p> Signup and view all the answers

The function 'load()' is used to import a dataframe into R.

<p>False (B)</p> Signup and view all the answers

What command is used to create a matrix combining two vectors in R?

<p>rbind() or cbind()</p> Signup and view all the answers

To calculate the average lifespan, you need to subtract the year of ______ from the year of death.

<p>birth</p> Signup and view all the answers

What does 'na.rm = TRUE' do when calculating the mean in R?

<p>It removes NA values from the calculation (D)</p> Signup and view all the answers

Match the following commands to their functions in R:

<p>read.table() = Imports a dataframe from a file save.image() = Saves the current workspace subset() = Filters data frames based on conditions class() = Returns the class of an object</p> Signup and view all the answers

The command 'dim(nobel)' returns the column names of the dataframe.

<p>False (B)</p> Signup and view all the answers

How is the average age of high creativity calculated from the Nobel dataset?

<p>By subtracting year of birth from year of research mid and calculating the mean.</p> Signup and view all the answers

Flashcards

Afficher les objets R

La commande ls() permet d'afficher la liste des objets chargés dans l'espace de travail R.

Supprimer les objets R

La commande rm(list=ls(all=TRUE)) permet de supprimer tous les objets chargés dans l'espace de travail R.

Répertoire de travail R

Le répertoire de travail est l'emplacement où R enregistre et lit les fichiers.

Enregistrer le workspace

La commande save.image("nom_fichier.Rdata") sauvegarde l'état actuel de votre espace de travail R dans un fichier.

Signup and view all the flashcards

Charger un workspace

La commande load("nom_fichier.Rdata") charge le workspace précédemment sauvegardé.

Signup and view all the flashcards

Affectation de valeur

L'opérateur = assigne une valeur à une variable.

Signup and view all the flashcards

Type d'objet

La fonction class() renvoie le type d'un objet (par exemple, vecteur, matrice, data.frame).

Signup and view all the flashcards

Créer un vecteur

La fonction c() crée un vecteur.

Signup and view all the flashcards

Créer une matrice

La fonction rbind() crée une matrice en empilant des vecteurs horizontalement. cbind() le fait verticalement.

Signup and view all the flashcards

Aide sur une fonction

La fonction ?fonction affiche la documentation d'une fonction.

Signup and view all the flashcards

Fonction avec paramètres

Les fonctions peuvent avoir des paramètres optionnels et obligatoires (par exemple, na.rm=TRUE dans la fonction mean()).

Signup and view all the flashcards

Fonction moyenne

La fonction mean() calcule la moyenne d'un vecteur.

Signup and view all the flashcards

Importation de données

La fonction read.table() importe des données d'un fichier texte. header=TRUE indique la présence d'un entête.

Signup and view all the flashcards

DataFrame

Un tableau de données avec des colonnes de types différents.

Signup and view all the flashcards

Dimensions d'un DataFrame

La fonction dim() renvoie le nombre de lignes et de colonnes d'un DataFrame.

Signup and view all the flashcards

Sous-ensembles de données

La fonction subset() permet de sélectionner des lignes d'un DataFrame qui correspondent à des conditions.

Signup and view all the flashcards

Displaying R objects

The ls() function displays the list of objects loaded into the R workspace.

Signup and view all the flashcards

Removing R objects

The rm(list=ls(all=TRUE)) command removes all the objects loaded into the R workspace.

Signup and view all the flashcards

Setting working directory

The setwd() function changes the current working directory to a specific folder.

Signup and view all the flashcards

Saving workspace

The save.image() function saves the current state of your R workspace to a file.

Signup and view all the flashcards

Loading workspace

The load() function loads a previously saved workspace into R.

Signup and view all the flashcards

Variable assignment

The = operator assigns a value to a variable.

Signup and view all the flashcards

Object type

The class() function returns the type of an object (e.g., vector, matrix, data frame).

Signup and view all the flashcards

Creating a vector

The c() function creates a vector.

Signup and view all the flashcards

Creating a matrix (horizontal)

The rbind() function creates a matrix by stacking vectors horizontally.

Signup and view all the flashcards

Creating a matrix (vertical)

The cbind() function creates a matrix by stacking vectors vertically.

Signup and view all the flashcards

Function help

The ?function_name command displays the documentation of a function.

Signup and view all the flashcards

Function parameters

Functions can have optional and mandatory parameters (e.g., na.rm=TRUE for mean()).

Signup and view all the flashcards

Calculate mean

The mean() function calculates the average of a vector.

Signup and view all the flashcards

Import data (text)

The read.table() function imports data from a text file.

Signup and view all the flashcards

Data frame

A data frame is a table-like structure with columns of different types.

Signup and view all the flashcards

Data frame dimensions

The dim() function returns the number of rows and columns of a data frame.

Signup and view all the flashcards

Data subset

The subset() function selects rows of a data frame based on conditions.

Signup and view all the flashcards

R workspace display

The ls() command shows a list loaded R objects.

Signup and view all the flashcards

Clear workspace

rm(list=ls(all=TRUE)) removes all R objects from memory.

Signup and view all the flashcards

Working directory

Sets the location where R saves or reads files.

Signup and view all the flashcards

Save workspace

Saves the current state of R's environment to a file.

Signup and view all the flashcards

Load workspace

Loads a previous R session from a file.

Signup and view all the flashcards

Variable assignment

Assigns a value to a variable using the = symbol.

Signup and view all the flashcards

Object type

class() returns the type of data (vector, matrix, etc.)

Signup and view all the flashcards

Create vector

c() combines values into an ordered sequence of data.

Signup and view all the flashcards

Matrix creation (horizontal)

rbind() combines vectors to form rows of a matrix.

Signup and view all the flashcards

Matrix creation (vertical)

cbind() combines vectors to form columns of a matrix.

Signup and view all the flashcards

Function help

?function_name displays documentation for a function in R

Signup and view all the flashcards

Function parameters

Functions in R have input values, some optional.

Signup and view all the flashcards

Mean calculation

mean() computes the average of a numeric vector.

Signup and view all the flashcards

Import data (text)

read.table() loads data from a text file in R.

Signup and view all the flashcards

Data frame

A data frame is a table structure with columns of different types.

Signup and view all the flashcards

Data frame dimensions

dim() returns the number of rows and columns in a data frame.

Signup and view all the flashcards

Data subset

subset() selects data frame rows meeting specific criteria.

Signup and view all the flashcards

More Like This

Use Quizgecko on...
Browser
Browser