Importer des données
R propose plusieurs fonctions pour importer des données à partir de différents formats :
- read.csv() : Pour importer des données au format CSV
- read_excel() (package readxl) : Pour importer des données au format Excel
- read_sas() (package haven) : Pour importer des données au format SAS
- read_stata() (package haven) : Pour importer des données au format Stata
- read_spss() (package haven) : Pour importer des données au format SPSS
Manipulation de données
R propose plusieurs fonctions pour manipuler des données :
- head() et tail() : Pour afficher les premières et dernières lignes d’un dataframe
- str() : Pour afficher la structure d’un dataframe
- summary() : Pour afficher un résumé statistique des variables d’un dataframe
- View() : Pour afficher un dataframe dans une interface graphique
- dim() : Pour afficher les dimensions d’un dataframe
- nrow() et ncol() : Pour compter le nombre de lignes et de colonnes d’un dataframe
- subset() : Pour sélectionner des lignes et des colonnes d’un dataframe
- filter() (package dplyr) : Pour filtrer des lignes d’un dataframe
- select() (package dplyr) : Pour sélectionner des colonnes d’un dataframe
- arrange() (package dplyr) : Pour trier un dataframe
- mutate() (package dplyr) : Pour créer de nouvelles variables dans un dataframe
- group_by() et summarise() (package dplyr) : Pour regrouper et résumer des données
Nettoyage de données
R propose plusieurs fonctions pour nettoyer des données :
- na.omit() : Pour supprimer les lignes contenant des valeurs manquantes
- is.na() et complete.cases() : Pour identifier les valeurs manquantes
- replace_na() (package tidyr) : Pour remplacer les valeurs manquantes
- drop_na() (package tidyr) : Pour supprimer les lignes contenant des valeurs manquantes
- fill() (package tidyr) : Pour remplir les valeurs manquantes avec les valeurs précédentes ou suivantes
Exploration de données
R propose plusieurs fonctions pour explorer des données :
- plot() : Pour créer des graphiques de base
- ggplot() (package ggplot2) : Pour créer des graphiques avancés
- hist() : Pour créer des histogrammes
- boxplot() : Pour créer des boîtes à moustaches
- density() : Pour créer des densités de probabilité
- cor() : Pour calculer les corrélations
- scale_color_manual() et scale_fill_manual() (package ggplot2) : Pour personnaliser les couleurs des graphiques
Ressources
- RStudio Cheat Sheets : https://rstudio.com/resources/cheatsheets/
- RStudio Data Wrangling with dplyr, tidyr, and tidyverse : https://rstudio.com/resources/webinars/data-wrangling-with-dplyr-tidyr-and-tidyverse/
- R for Data Science : http://r4ds.had.co.nz/
- DataCamp R Courses : https://www.datacamp.com/courses/intro-to-r
Importing data
R offers several functions for importing data from different formats:
- read.csv() : To import data in CSV format
- read_excel() (readxl package): To import data in Excel format
- read_sas() (package haven): To import data in SAS format
- read_stata() (haven package) : To import data in Stata format
- read_spss() (haven package) : To import data in SPSS format
Data manipulation
R offers several functions for manipulating data:
- head() and tail() : Display the first and last lines of a dataframe
- str() : To display the structure of a dataframe
- summary() : To display a statistical summary of a dataframe’s variables
- View() : To display a dataframe in a graphical interface
- dim() : To display the dimensions of a dataframe
- nrow() and ncol() : To count the number of rows and columns in a dataframe
- subset() : Select rows and columns of a dataframe
- filter() (package dplyr): To filter rows in a dataframe
- select() (package dplyr) : To select dataframe columns
- arrange() (package dplyr) : To sort a dataframe
- mutate() (package dplyr) : Create new variables in a dataframe
- group_by() and summarise() (package dplyr): To group and summarize data
Data cleansing
R offers several functions for cleaning data:
- na.omit() : To remove rows containing missing values
- is.na() and complete.cases(): To identify missing values
- replace_na() (package tidyr): Replaces missing values
- drop_na() (package tidyr): Deletes rows containing missing values
- fill() (package tidyr): Fill missing values with previous or next values
Data exploration
R offers several functions for exploring data:
- plot() : To create basic graphs
- ggplot() (package ggplot2): To create advanced plots
- hist() : To create histograms
- boxplot() : To create boxplots
- density() : To create probability densities
- cor() : To calculate correlations
- scale_color_manual() and scale_fill_manual() (package ggplot2): Customize graph colors
Resources
- RStudio Cheat Sheets: https://rstudio.com/resources/cheatsheets/
- RStudio Data Wrangling with dplyr, tidyr, and tidyverse: https://rstudio.com/resources/webinars/data-wrangling-with-dplyr-tidyr-and-tidyverse/
- R for Data Science: http://r4ds.had.co.nz/
- DataCamp R Courses: https://www.datacamp.com/courses/intro-to-r