[PDF] Introduction aux graphiques avec R - CEL





Previous PDF Next PDF



Histogramme et courbe de densité de Kernel

13 avr. 2015 de base en R accompagné d'explications ensuite un graphique simple avec des fonctions du package ggplot2 accompagné d'explications et ...



Optimiser ses graphiques avec R

28 avr. 2011 ggplot2. Références. Base – Fonctions de haut-niveau nuages de points profils graphiques en bâtons histogrammes bo?tes `a moustaches.



Aide mémoire GGplot2 en français

h <- ggplot(diamonds aes(cut



analyse-R.pdf

26 avr. 2022 analyse-R – Introduction à l'analyse d'enquêtes avec R et RStudio ... Introduction à ggplot2 la grammaire des graphiques .



Visualisation avec R

12 janv. 2022 1. ggplot2 : un package R pour visualiser les données =? 3-4h. ... Histogramme pour une variable continue diagramme en barres pour.



Logiciel R et programmation

Puis changer la représentation géométrique pour afficher un histogramme des résidus ; ggplot(data = residus_df



Visualisation avec R

12 janv. 2022 1. ggplot2 : un package R pour visualiser les données =? 3-4h. ... Histogramme pour une variable continue diagramme en barres pour une ...



Introduction aux graphiques avec R - CEL

30 oct. 2016 4 ggplot2 : pour commencer ... Pour avoir un aperçu des possibilités graphiques du logiciel R ... alors d'un histogramme des effectifs.



graphiques.pdf

Créer des graphiques en R peut se faire à l'aide de plusieurs packages : Les éléments de la grammaire graphique de ggplot2 sont :.



Data Visualization with ggplot2 : : CHEAT SHEET

ggplot2 is based on the grammar of graphics the idea that you can build every graph from the same components: a data set a coordinate system and geoms—visual marks that represent data points Basics GRAPHICAL PRIMITIVES a + geom_blank() (Useful for expanding limits)



R Handouts 2019-20 Data Visualization with ggplot2 - UMass

Apr 17 2014 · In this illustration you will learn how to produce some basic graphs (hopefully some useful ones!) using the package ggplot2 You will be using an R dataset that you import directly into R Studio Before You Begin: Be sure to have downloaded from the course website: framingham Rdata



Create ggplot2 Histogram in R (7 Examples) - Statistics Globe

Package ‘ggplot2’ April 3 2023 Version 3 4 2 Title Create Elegant Data Visualisations Using the Grammar of Graphics Description A system for 'declaratively' creating graphics based on ``The



Chapter 2 R ggplot2 Examples - University of Wisconsin–Madison

1 1 Installing R the Lock5Data package and ggplot2 Install R onto your computer from the CRAN website (cran r-project org) CRAN is a reposi-tory for all things R Follow links for your appropriate operating system and install in the normalway After installing R download theLock5Dataandggplot2packages



An Introduction to ggplot2 - Stanford University

ggplot2is part of tidyverse by Hadley WickhamSyntax is based onThe Grammar of Graphicsby Leland Wilkinson $140 new on AmazonAvailable online for Stanford a?liates at https://ebookcentral proquest com/lib/stanford-ebooks/detail action?docID=302755But I’ve never looked at this book Basically build sentences:



A Graphical EDA Tool with ggplot2: brinton - The R Journal

A Graphical EDA Tool with ggplot2: brinton by Pere Millán-Martínez Ramon Oller Abstract We present brinton package which we developed for graphical exploratory data analysis in R Based on ggplot2 gridExtra and rmarkdown brinton package introduces wideplot() graphics for exploring the structure of a dataset through a grid of variables and



Data visualization with ggplot2 : : CHEAT SHEET - GitHub

ggplot2 is based on the grammar of graphics the idea that you can build every graph from the same components: a data set a coordinate system and b geoms—visual marks that represent data points Basics GRAPHICAL PRIMITIVES a + geom_blank() and a + expand_limits() Ensure limits include values across all plots



ggExtra: Add Marginal Histograms to 'ggplot2' and More

Create a ggplot2 scatterplot with marginal density plots (default) or histograms or add the marginalplots to an existing scatterplot Usage ggMarginal( p data x y type = c("density" "histogram" "boxplot" "violin" "densigram") margins = c("both" "x" "y") size = 5 xparams = list() yparams = list() groupColour = FALSE



Stat 849: ggplot2 graphics - University of Wisconsin–Madison

The ggplot2 graphics package Another advanced graphics package for R is ggplot2 by Hadley Wickham (a recent Iowa State Stats Ph D now at Rice) His book is listed as one of the references on the course web site The core chapter introducing the basic function called qplot can be obtained from the URL in the links section on the course web site



GGPlot2 Essentials - Datanovia

GGPlot2 is a powerful and a flexible R package implemented by Hadley Wickham for pro- ducing elegant graphics piece by piece ggplot2 has become a popular package for data visualization The official documentation of the package is available at: https://ggplot2 tidyverse org/reference/



Introduction to R - Winona State University

• Graphics System: ggplot2 • Type of Plot: boxplot • x-variable: Kitchen Qualrepresenting the condition of the sale • y-variable: SalePrice After selecting these items click theShow Expressionto see the ggplot2code used to make the boxplot Now modify the code to add an appropriate title to the plot



Searches related to histogramme r ggplot2 filetype:pdf

Build your ggplot plot layer by layer editing and correcting as you go along! How to Build Your Plot Layer by Layer: Step 1: Attach packages Either of the following works library(ggplot2) or library(tidyverse) Step 2 (optional recommended): Create each plot in an R Script or in its own R Markdown chunk

How do you plot a histogram with ggplot in R?

  • If we want to create a histogram with the ggplot2 package, we need to use the geom_histogram function. The R code of Example 1 shows how to draw a basic ggplot2 histogram. Figure 1 visualizes the output of the previous R syntax: A histogram in the typical design of the ggplot2 package.

What are the advantages of using ggplot2 for creating a histogram?

  • If you need to create a histogram in R, I strongly recommend that you use ggplot2 instead. ggplot2 is a powerful plotting library that gives you great control over the look and layout of the plot. The syntax is easier to modify, and the default plots are fairly beautiful.

What is the best way to adjust the binwidth of a ggplot2 histogram in R?

  • The following R programming syntax shows how to increase the binwidth of the bars in a ggplot2 histogram. For this task, we can apply the binwidth argument of the geom_histogram function as shown below: ggplot ( data, aes ( x)) + # Increase binwidth geom_histogram ( col = "#1b98e0" , binwidth = 1)

What is the best way to plot a histogram with density in R?

  • If you need to create a histogram in R, I strongly recommend that you use ggplot2 instead. ggplot2 is a powerful plotting library that gives you great control over the look and layout of the plot. The syntax is easier to modify, and the default plots are fairly beautiful.

Université de Caen

Introduction aux graphiques avecChristophe Chesneau http://www.math.unicaen.fr/ ~chesneau/Caen, le 25 Août 2016

TABLE DES MATIÈRES

Table des matières

1 Point de départ5

2 Créer un ou plusieurs graphiques 7

2.1 La commandestripchart. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .7

2.2 La commandedotchart. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .7

2.3 La commandeplot. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .8

2.4 La commandecurve. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .18

2.5 La commandebarplot. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .21

2.6 La commandepie. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .27

2.7 La commandehist. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .27

2.8 La commandeboxplot. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .32

2.9 Avoir plusieurs graphiques sur la même fenêtre . . . . . . . . . . . . . . . . . . . . . .

34

2.10 Avoir plusieurs graphiques successifs . . . . . . . . . . . . . . . . . . . . . . . . . . . .

34

3 Additionner un graphique à un graphique existant 35

3.1 La commandepoints. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .35

3.2 La commandelines. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .36

3.3 La commandetext. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .36

3.4 La commandeabline. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .38

3.5 Les commandescurve(f(x), add = TRUE). . . . . . . . . . . . . . . . . . . . . . . .38

3.6 La commandesegments. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .39

3.7 La commandetitle. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .40

3.8 La commandeaxis. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .41

3.9 La commandelegend. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .42

3.10 La commandegrid. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .44

3.11 Les problèmes d"échelles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

44

4ggplot2: pour commencer 45C. Chesneau3

TABLE DES MATIÈRES

5 Exercices51

6 Solutions61

Note L"objectif de ce document est de présenter les principales commandes graphiques offertes par le logiciel R. Contact :christophe.chesneau@gmail.com

Bonne lecture!C. Chesneau4

1 POINT DE DÉPART

1 Point de départ

Pour avoir un aperçu des possibilités graphiques du logiciel R, on fait : demo(graphics)Taper sur la touche "Entrée" pour faire défiler plusieurs graphiques. On obtient, entre autre, celui là :Une fois que plus rien ne s"affiche, on fait : dev.off()Ces graphiques sont obtenus à l"aide de commandes. On en distingue trois sortes : celles quicréen tune figure graphique dan sune fenêtre, celles quia joutentune figure graphique à la fenêtr eexistan te, celles quimo difientles pa ramètresdu graphisme. Pour illustrer ces commandes, on considèrera dès que possible le jeu de données "enquete" : enquete = read.table("http://www.math.unicaen.fr/ ~chesneau/enquete.txt", header = T) attach(enquete) str(enquete)C. Chesneau5

2 CRÉER UN OU PLUSIEURS GRAPHIQUES

2 Créer un ou plusieurs graphiques

2.1 La commandestripchart

L"utilisation de base eststripchart(x), oùxdésigne un vecteur numérique. On affiche alors les valeurs ordonnées des éléments dexsur un axe permettant de juger de la dispersion des valeurs.

On fait :

stripchart(poids)Cela renvoie :

2.2 La commandedotchart

L"utilisation de base estdotchart(x), oùxdésigne un vecteur numérique.C. Chesneau7

2 CRÉER UN OU PLUSIEURS GRAPHIQUES

La valeur de chaque élément dexest affichée sur une ligne différente. Pour faciliter l"étude de la

dispersion des valeurs, il convient d"ordonner les valeurs.

On fait :

dotchart(sort(poids))Cela renvoie : Notons que, si plusieurs graphiques se succèdent, seul le dernier apparait.

2.3 La commandeplot

Utilisation de base

L"utilisation de base estplot(x, y), oùxetysont2vecteurs de même longueur. On construit alors un nuage de points dont lei-ème point est de coordonnées(x[i], y[i]). Si un seul vecteuryest indiqué, on un nuage de points dont lei-ème point est de coordonnées (i, y[i]).

On fait :

plot(poids)C. Chesneau8

2 CRÉER UN OU PLUSIEURS GRAPHIQUES

Cela renvoie :

On fait :

plot(c(4, 1, 2, 6, 5, 9, 7, 10, 3, 8), poids)Cela renvoie :

C. Chesneau9

2 CRÉER UN OU PLUSIEURS GRAPHIQUES

Options graphiques

Il existe des options dansplotpermettant de changer les paramètres graphiques. On les active en rajoutant une ou plusieurs commandes dansplot. Par exemple, on fait :

plot(poids, type = "l", lty = 2, axes = F, main = "poids des personnes")Quelques options sont présentées ci-dessous.

Option :type.On considère les command estype = "c" sic = p, seul le nuage de point est construit (pest l"option par défaut), sic = n, seul l"encadrement est tracé, sic = l, les points sont reliés par une ligne, sic = h, des lignes verticales sont tracées, sic = oou sic = b, les points sont marqués et reliés par une ligne.

On considère les commandes :

plot(poids, type = "o")Cela renvoie : Option :xlab.Les c ommandesxlab = "string"etylab = "string", oùstringest une chaine de

caractères, donnent un nom aux axes des coordonnées. Par défaut, ce sont les noms dexety.C. Chesneau10

2 CRÉER UN OU PLUSIEURS GRAPHIQUES

On considère les commandes :

plot(poids, type = "b", xlab = "numero")Cela renvoie : Option :pch.Les commandes pch = n, oùnest un entier ou un caractère, changent la nature des points du graphique.

On considère les commandes :

plot(poids, pch = 4, xlab = "numero")C. Chesneau11

2 CRÉER UN OU PLUSIEURS GRAPHIQUES

Cela renvoie :

On fait :

plot(poids, type = "b", pch = "a", xlab = "numero")Cela renvoie :

C. Chesneau12

2 CRÉER UN OU PLUSIEURS GRAPHIQUES

Option :xlim.Les commandes xlim = c(a, b)et/ouylim = c(a, b), oùaetbsont deux nombres réels, imposent des limites aux axes.

On considère les commandes :

plot(poids, type = "b", xlab = "numero", xlim = c(-10, 20), ylim = c(30,90))Cela renvoie : Option :xaxt.L escommand esxaxt = "n"et/ouyaxt = "n"effacent à la fois les tirets qui marquent les axes et les valeurs qui correspondent à ces tirets.

On fait :

plot(poids, type = "b", xlab = "numero", xlim= c(-10, 20), ylim = c(30, 90))C. Chesneau13

2 CRÉER UN OU PLUSIEURS GRAPHIQUES

Cela renvoie :

Option :col.Les commandes col = "string", oùstringest une couleur :red,yellow,green, blue...ajoutent de la couleur.

On fait :

plot(poids, pch = 19, xlab = "numero", col = "red")Cela renvoie :

C. Chesneau14

2 CRÉER UN OU PLUSIEURS GRAPHIQUES

On peut aussi utiliser :

des fonctions générant des couleurs par les commandescol = rainbow(n),col = heat.color(n), col = terrain.colors(n),col = topo.colors(n),col = cm.colors(n), oùndésigne un en- tier.

des codes hexadécimaux avec les2premières uintés pour le rouge, les deux suivantes pour le vert

et les deux dernières pour le bleu :col = "#120019",col = "#123418",col = "#1200FF"...

Option :cex.Les commandes cex = l, oùlest un réel positif, multiplient la taille des caractères conte-

nus dans la fenêtre parl. De même, les commandescex.axis = lmultiplient la taille des caractères

indiquant les étiquettes des axes parl.

On fait :

plot(poids, pch = "a", xlab = "numero", cex = 3)Cela renvoie :

Option :lty.Les commandes lty = m, oùmest un entier, changent la nature des lignes qui relient les

points.

On considère les commandes :

plot(poids, type = "l", lty = 2)C. Chesneau15

2 CRÉER UN OU PLUSIEURS GRAPHIQUES

Cela renvoie :

Option :axes.Les commandes axes = Feffacent l"entourage de la fenêtre.

On fait :

plot(poids, type = "l", lty = 2, axes = F)Cela renvoie :

C. Chesneau16

2 CRÉER UN OU PLUSIEURS GRAPHIQUES

Option :main.Les comman desmain = "string", oùstringest une chaîne de caractères, mettent un

titre au graphe.

On fait :

plot(poids, type = "l", main = "poids des personnes")Cela renvoie : Option :lwd.Les co mmandeslwd = m, oùmest un entier, changent l"épaisseur des lignes/traits du graphe.

On fait :

plot(poids, type = "l", lwd = 5)C. Chesneau17

2 CRÉER UN OU PLUSIEURS GRAPHIQUES

Cela renvoie :

Pour plus de détails sur les options deplot, fairehelp("plot"). Cela vaut aussi pour les commandes

à venir.

2.4 La commandecurve

La commandecurvesert à confectionner rapidement certaines courbes représentatives de fonctions.

On peut notamment l"utiliser pour représenter la densité et la fonction de répartition des lois d"une

variable à densité. Pour dessiner la courbe représentative d"une fonctionf(x)entreaetb, on fait : curve(f(x), a, b)

On considère les commandes :

curve(sin(x), -3, 10)C. Chesneau18

2 CRÉER UN OU PLUSIEURS GRAPHIQUES

Cela renvoie :

On considère les commandes :

fonc = function(x) { sin(cos(x) * exp( -x / 2)) } curve(fonc, -8, 7)Cela renvoie :

C. Chesneau19

2 CRÉER UN OU PLUSIEURS GRAPHIQUES

On peut augmenter le nombre de pointsnà discrétiser entreaetben faisant : curve(fonc, -8, 7, n = 2001)Cela renvoie : On peut changer l"épaisseur de la courbe en faisant : curve(fonc, -8, 7, lwd = 5)Cela renvoie :

C. Chesneau20

2 CRÉER UN OU PLUSIEURS GRAPHIQUES

La plupart des options deplot(col,lwd...) peuvent aussi être rajoutées danscurve.

2.5 La commandebarplot

Utilisation de base

Pour un vecteurxànéléments, les commandesbarplot(x)donnentnbarres verticales, lai-ème barre étant de hauteur proportionnelle àx[i]. On fait : barplot(poids)Cela renvoie :

Utilisation en statistique

La commandebarplotpeut servir à :

représenter la série brute de données issues d"une variable quantitative (quand l"effectif n"est pas

trop grand) en confectionnant un diagramme en barres ou un diagramme en bandeaux. représenter la distribution d"une variable qualitative (en effectifs et/ou en fréquence). On rappelle que cette distribution s"obtient en associant à chaque modalitémique peut prendre la variable, l"effectifniet/ou la fréquenceni=n. Dans ce cas, on a toujours en abscisse, les

modalités pouvant être prises par la variable et, en ordonnée, l"effectif ou la fréquence.C. Chesneau21

2 CRÉER UN OU PLUSIEURS GRAPHIQUES

On fait :

barplot(table(couleur))Cela renvoie : représenter la distribution en effectif et/ou en fréquence d"une variable discrète.

On fait :

barplot(table(nb))Cela renvoie :

C. Chesneau22

2 CRÉER UN OU PLUSIEURS GRAPHIQUES

Options graphiques

Comme pourplot, il existe des options dansbarplotpermettant de changer les paramètres gra- phiques. On les active en rajoutant une ou plusieurs commandes dansbarplot.

Par exemple, on fait :

barplot(poids, xlim = c(-3, 33), width = 0.8)Quelques options sont présentées ci-dessous.

Option :space.Les commandes space = l, oùlest un nombre réel, changent l"écartement entre les

barres qui seront espacées de ?l fois la largeur moyenne des barres.

On fait :

barplot(poids, space = 2)Cela renvoie : Option :xlim.Les commandes xlim = c(a, b)et/ouylim = c(a, b), oùaetbsont deux nombres réels, imposent des limites aux axes.

On fait :

barplot(poids, xlim = c(-3, 13), ylim = c(0, 100))C. Chesneau23

2 CRÉER UN OU PLUSIEURS GRAPHIQUES

Cela renvoie :

Option :width.Si l"opt ionxlima été utilisée, on peut spécifier la largeur des barres parwidth = d,

oùdest la largeur souhaitée.

On considère les commandes :

barplot(poids, xlim = c(-3, 33), width = 0.8)Cela renvoie :

C. Chesneau24

2 CRÉER UN OU PLUSIEURS GRAPHIQUES

Option :names.arg.Les commandes names.arg = string, oùstringest un vecteur de chaîne de caractères, attribuent le nom dui-ème élément destringà lai-ème barre.

On considère les commandes :

prenoms = c("Karen", "Elodie", "Paul", "Paul", "Elsa", "Karen", "Aurelie", "Elsa", "Karen", "Sophie") barplot(poids, space = 2, names.arg = prenoms)Cela renvoie : Les prénoms attribués prennent trop de place, c"est pourquoi ils ne sont pas tous affichés.

Une solution est :

barplot(poids, space = 2, names.arg = prenoms, cex.names = 0.4)C. Chesneau25

2 CRÉER UN OU PLUSIEURS GRAPHIQUES

Cela renvoie :

Option :horiz.Les comma ndeshoriz = L, oùLestTRUEouFALSE, tracent les barres à l"horizontale siL = TRUEet à la verticale sinon.

On fait :

barplot(poids, horiz = TRUE)Cela renvoie :

C. Chesneau26

2 CRÉER UN OU PLUSIEURS GRAPHIQUES

La plupart des options deplot(col,lwd...) peuvent aussi être rajoutées dansbarplot.

2.6 La commandepie

La commande basique estpie(x), oùxest un vecteur de longueurl. Elle constitue un diagramme

àpsecteurs. Elle est principalement utilisée pour représenter la distribution d"une variable qualitative

àlmodalités.

On fait :

pie(table(couleur))Cela renvoie :

2.7 La commandehist

La commande basique esthist(x)ouhist(x, prob = TRUE), oùxest un vecteur de longueurn.C. Chesneau27

2 CRÉER UN OU PLUSIEURS GRAPHIQUES

Cette commande :

construit automatiquement une suite delclasses adjacentes[0;1];]1;2];:::;]l1;l]telles que l"ensemble des valeurs dexest inclus dans[0;l]et ceci suivant une règle dite de Sturges. Par défaut, les classes sont de même amplitude. calcule automatiquement la distribution en effectifs de série des donnéesxdans les classes ci-

dessus,iela série desnjoùnjest l"effectif des données qui appartiennent à la classe]j1;j].

construitlrectangles accolés. On distingue alors2possibilités : Par défaut; siprob = FALSE:la hauteur du rectangle pour la classejest égale ànj. Il s"agit alors d"un histogramme des effectifs. Sur le graphe, les ordonnées sont notées (Frequency) alors qu"en réalité, il s"agit bien des effectifs. Siprob = TRUE:la hauteurhjdu rectangle pour la classejest égale àfj=ajoùfj=nj=n fréquence de la classejet oùaj=jj1amplitude de la classej. Il s"agit alors d"un histogramme des fréquences. Sur le graphe, les ordonnées sont indiquées (Density).

On fait :

hist(poids)Cela renvoie :

C. Chesneau28

2 CRÉER UN OU PLUSIEURS GRAPHIQUES

On considère les commandes :

hist(poids, prob = TRUE)Cela renvoie :

Options graphiques

Comme pourplot, il existe des options danshistpermettant de changer les paramètres graphiques. On les active en rajoutant une ou plusieurs commandes danshist. Par exemple, on fait : hist(poids, breaks = c(45, 60, 75), prob = T)Quelques options sont présentées ci-dessous.

Option :break.Les commandes breaks = x, oùxest un vecteur numérique, donnent les extrémités

des classes.

On considère les commandes :

hist(poids,breaks = c(45, 60, 75))C. Chesneau29

2 CRÉER UN OU PLUSIEURS GRAPHIQUES

Cela renvoie :

On considère les commandes :

hist(poids,breaks = c(45, 60, 75), prob = TRUE)Cela renvoie :

C. Chesneau30

2 CRÉER UN OU PLUSIEURS GRAPHIQUES

Notons que l"histogramme obtenu a même allure que le précédent mais on se trouve dans le deuxième

cas et les hauteurs des rectangles sont maintenant des densités.

On fait :

hist(poids,breaks = c(45, 50, 70, 75))Cela renvoie : Ainsi, le fait que les classes ne soient plus d"amplitudes égales active l"optionprob = TRUE. Option :right.Les commandes right = L, oùLestTRUEouFALSE, considèrent des intervalles de la forme]j1;j]siL = TRUE, sinon de la forme[j1;j[.

On fait :

hist(poids, right = FALSE)C. Chesneau31

2 CRÉER UN OU PLUSIEURS GRAPHIQUES

Cela renvoie :

La plupart des options deplot(col,lwd...) peuvent aussi être rajoutées danshist.

2.8 La commandeboxplot

La commande basique estboxplot(x), oùxest un vecteur de longueurn. Elle construit la boîte à

moustaches dex.

On fait :

boxplot(poids)C. Chesneau32

2 CRÉER UN OU PLUSIEURS GRAPHIQUES

Cela renvoie :

Pour construire une boîte à moustaches dexpour chaque élément d"un vecteury, on fait : boxplot(x ~y)

On fait :

boxplot(poids ~couleur)Cela renvoie :

C. Chesneau33

2 CRÉER UN OU PLUSIEURS GRAPHIQUES

2.9 Avoir plusieurs graphiques sur la même fenêtre

Les commandespar(mfrow = c(k, l)), oùketlsont des entiers, servent à découper l"écran en

klignes etlcolonnes. Lorsque plusieurs commandes créant un graphique se succèdent, ces graphiques

se positionnent par ligne sur les cases ainsi créées. Si on veut qu"ils se positionnent par colonne, on faitpar(mfcol = c(k, l)).

On fait :

par(mfrow = c(2, 1)) hist(poids) plot(poids)Cela renvoie : Pour revenir à la configuration de départ, on faitpar(mfrow = c(1, 1)).

2.10 Avoir plusieurs graphiques successifs

Les commandespar(ask = TRUE)affichent plusieurs graphiques successivement.C. Chesneau34

3 ADDITIONNER UN GRAPHIQUE À UN GRAPHIQUE EXISTANT

On considère les commandes :

par(ask = TRUE) hist(poids) plot(poids)Pour revenir à la configuration de départ, on faitpar(ask = FALSE).

3 Additionner un graphique à un graphique existant

3.1 La commandepoints

L"utilisation de base estpoints(x, y), oùxetysont2vecteurs de même longueur. Cela ajoute à la figure existante un nuage de points associé à(x, y).

On fait :

plot(poids) points(c(2, 2, 6.3), c(55, 60, 70), cex = 2, pch = 5, col = "red")Cela renvoie :

C. Chesneau35

3 ADDITIONNER UN GRAPHIQUE À UN GRAPHIQUE EXISTANT

3.2 La commandelines

L"utilisation de base estlines(x, y), oùxetysont2vecteurs de même longueur.

Cela ajoute à la figure existante une ligne reliant les points du nuage de points associé à(x, y).

On fait :

plot(poids) lines(1:8, rep(60, 8) + c(-10, 10), lty = 3)Cela renvoie :

3.3 La commandetext

quotesdbs_dbs21.pdfusesText_27
[PDF] histogramme r variable qualitative

[PDF] histoire 2nde magnard 2010 corrigé

[PDF] histoire 4ème les traites négrières et l esclavage

[PDF] histoire 4ème les traites négrières et l'esclavage

[PDF] histoire afro américaine

[PDF] histoire aventure fantastique

[PDF] histoire canada chronologie

[PDF] histoire contemporaine définition

[PDF] histoire d afrique noire

[PDF] histoire d'amour ado

[PDF] histoire d'amour courte a lire

[PDF] histoire d'amour en francais

[PDF] histoire d'amour qui fait pleurer

[PDF] histoire d'amour romantique

[PDF] histoire damour triste vrai et courte