-
Notifications
You must be signed in to change notification settings - Fork 42
/
formater-nombres.html
918 lines (822 loc) · 57.2 KB
/
formater-nombres.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
<!DOCTYPE html>
<html lang="fr" xml:lang="fr">
<head>
<meta charset="utf-8" />
<meta name="generator" content="pandoc" />
<meta http-equiv="X-UA-Compatible" content="IE=EDGE" />
<title>Mettre en forme des nombres avec scales</title>
<script src="libs/header-attrs-2.25/header-attrs.js"></script>
<script src="libs/jquery-3.6.0/jquery-3.6.0.min.js"></script>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link href="libs/bootstrap-3.3.5/css/paper.min.css" rel="stylesheet" />
<script src="libs/bootstrap-3.3.5/js/bootstrap.min.js"></script>
<script src="libs/bootstrap-3.3.5/shim/html5shiv.min.js"></script>
<script src="libs/bootstrap-3.3.5/shim/respond.min.js"></script>
<style>h1 {font-size: 34px;}
h1.title {font-size: 38px;}
h2 {font-size: 30px;}
h3 {font-size: 24px;}
h4 {font-size: 18px;}
h5 {font-size: 16px;}
h6 {font-size: 12px;}
code {color: inherit; background-color: rgba(0, 0, 0, 0.04);}
pre:not([class]) { background-color: white }</style>
<script src="libs/navigation-1.1/tabsets.js"></script>
<link href="libs/pagedtable-1.1/css/pagedtable.css" rel="stylesheet" />
<script src="libs/pagedtable-1.1/js/pagedtable.js"></script>
<link href="libs/anchor-sections-1.1.0/anchor-sections.css" rel="stylesheet" />
<link href="libs/anchor-sections-1.1.0/anchor-sections-hash.css" rel="stylesheet" />
<script src="libs/anchor-sections-1.1.0/anchor-sections.js"></script>
<meta name="robots" content="index, follow">
<link rel="stylesheet" href="./include/analyse-R.css" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/2.0.4/clipboard.min.js"></script>
<script type="text/javascript" src="./libs/bigfoot-2.1.4/bigfoot.min.js"></script>
<link rel="stylesheet" href="./libs/bigfoot-2.1.4/bigfoot-number.css" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" integrity="sha256-eZrrJcwDc/3uDhsdt61sL2oOBY362qM3lon1gyExkL0=" crossorigin="anonymous">
<link rel="stylesheet" href="./libs/colorbox-1.6.1/colorbox.css" />
<script type="text/javascript" src="./libs/colorbox-1.6.1/jquery.colorbox-min.js"></script>
<!--- favicon --->
<link rel="apple-touch-icon" sizes="57x57" href="./images/favicon/apple-icon-57x57.png">
<link rel="apple-touch-icon" sizes="60x60" href="./images/favicon/apple-icon-60x60.png">
<link rel="apple-touch-icon" sizes="72x72" href="./images/favicon/apple-icon-72x72.png">
<link rel="apple-touch-icon" sizes="76x76" href="./images/favicon/apple-icon-76x76.png">
<link rel="apple-touch-icon" sizes="114x114" href="./images/favicon/apple-icon-114x114.png">
<link rel="apple-touch-icon" sizes="120x120" href="./images/favicon/apple-icon-120x120.png">
<link rel="apple-touch-icon" sizes="144x144" href="./images/favicon/apple-icon-144x144.png">
<link rel="apple-touch-icon" sizes="152x152" href="./images/favicon/apple-icon-152x152.png">
<link rel="apple-touch-icon" sizes="180x180" href="./images/favicon/apple-icon-180x180.png">
<link rel="icon" type="image/png" sizes="192x192" href="./images/favicon/android-icon-192x192.png">
<link rel="icon" type="image/png" sizes="32x32" href="./images/favicon/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="96x96" href="./images/favicon/favicon-96x96.png">
<link rel="icon" type="image/png" sizes="16x16" href="./images/favicon/favicon-16x16.png">
<link rel="manifest" href="./images/favicon/manifest.json">
<meta name="msapplication-TileColor" content="#ffffff">
<meta name="msapplication-TileImage" content="./images/favicon/ms-icon-144x144.png">
<meta name="theme-color" content="#ffffff">
<!-- Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-86STMQ5JPT"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-86STMQ5JPT');
</script>
<style type="text/css">
code{white-space: pre-wrap;}
span.smallcaps{font-variant: small-caps;}
span.underline{text-decoration: underline;}
div.column{display: inline-block; vertical-align: top; width: 50%;}
div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;}
ul.task-list{list-style: none;}
.display.math{display: block; text-align: center; margin: 0.5rem auto;}
</style>
<style type="text/css">
code {
white-space: pre;
}
.sourceCode {
overflow: visible;
}
</style>
<style type="text/css" data-origin="pandoc">
pre > code.sourceCode { white-space: pre; position: relative; }
pre > code.sourceCode > span { display: inline-block; line-height: 1.25; }
pre > code.sourceCode > span:empty { height: 1.2em; }
.sourceCode { overflow: visible; }
code.sourceCode > span { color: inherit; text-decoration: inherit; }
div.sourceCode { margin: 1em 0; }
pre.sourceCode { margin: 0; }
@media screen {
div.sourceCode { overflow: auto; }
}
@media print {
pre > code.sourceCode { white-space: pre-wrap; }
pre > code.sourceCode > span { text-indent: -5em; padding-left: 5em; }
}
pre.numberSource code
{ counter-reset: source-line 0; }
pre.numberSource code > span
{ position: relative; left: -4em; counter-increment: source-line; }
pre.numberSource code > span > a:first-child::before
{ content: counter(source-line);
position: relative; left: -1em; text-align: right; vertical-align: baseline;
border: none; display: inline-block;
-webkit-touch-callout: none; -webkit-user-select: none;
-khtml-user-select: none; -moz-user-select: none;
-ms-user-select: none; user-select: none;
padding: 0 4px; width: 4em;
color: #aaaaaa;
}
pre.numberSource { margin-left: 3em; border-left: 1px solid #aaaaaa; padding-left: 4px; }
div.sourceCode
{ }
@media screen {
pre > code.sourceCode > span > a:first-child::before { text-decoration: underline; }
}
code span.al { color: #ff0000; font-weight: bold; } /* Alert */
code span.an { color: #60a0b0; font-weight: bold; font-style: italic; } /* Annotation */
code span.at { color: #7d9029; } /* Attribute */
code span.bn { color: #40a070; } /* BaseN */
code span.bu { color: #008000; } /* BuiltIn */
code span.cf { color: #007020; font-weight: bold; } /* ControlFlow */
code span.ch { color: #4070a0; } /* Char */
code span.cn { color: #880000; } /* Constant */
code span.co { color: #60a0b0; font-style: italic; } /* Comment */
code span.cv { color: #60a0b0; font-weight: bold; font-style: italic; } /* CommentVar */
code span.do { color: #ba2121; font-style: italic; } /* Documentation */
code span.dt { color: #902000; } /* DataType */
code span.dv { color: #40a070; } /* DecVal */
code span.er { color: #ff0000; font-weight: bold; } /* Error */
code span.ex { } /* Extension */
code span.fl { color: #40a070; } /* Float */
code span.fu { color: #06287e; } /* Function */
code span.im { color: #008000; font-weight: bold; } /* Import */
code span.in { color: #60a0b0; font-weight: bold; font-style: italic; } /* Information */
code span.kw { color: #007020; font-weight: bold; } /* Keyword */
code span.op { color: #666666; } /* Operator */
code span.ot { color: #007020; } /* Other */
code span.pp { color: #bc7a00; } /* Preprocessor */
code span.sc { color: #4070a0; } /* SpecialChar */
code span.ss { color: #bb6688; } /* SpecialString */
code span.st { color: #4070a0; } /* String */
code span.va { color: #19177c; } /* Variable */
code span.vs { color: #4070a0; } /* VerbatimString */
code span.wa { color: #60a0b0; font-weight: bold; font-style: italic; } /* Warning */
</style>
<script>
// apply pandoc div.sourceCode style to pre.sourceCode instead
(function() {
var sheets = document.styleSheets;
for (var i = 0; i < sheets.length; i++) {
if (sheets[i].ownerNode.dataset["origin"] !== "pandoc") continue;
try { var rules = sheets[i].cssRules; } catch (e) { continue; }
var j = 0;
while (j < rules.length) {
var rule = rules[j];
// check if there is a div.sourceCode rule
if (rule.type !== rule.STYLE_RULE || rule.selectorText !== "div.sourceCode") {
j++;
continue;
}
var style = rule.style.cssText;
// check if color or background-color is set
if (rule.style.color === '' && rule.style.backgroundColor === '') {
j++;
continue;
}
// replace div.sourceCode by a pre.sourceCode rule
sheets[i].deleteRule(j);
sheets[i].insertRule('pre.sourceCode{' + style + '}', j);
}
}
})();
</script>
<style type = "text/css">
.main-container {
max-width: 940px;
margin-left: auto;
margin-right: auto;
}
img {
max-width:100%;
}
.tabbed-pane {
padding-top: 12px;
}
.html-widget {
margin-bottom: 20px;
}
button.code-folding-btn:focus {
outline: none;
}
summary {
display: list-item;
}
details > summary > p:only-child {
display: inline;
}
pre code {
padding: 0;
}
</style>
<!-- tabsets -->
<style type="text/css">
.tabset-dropdown > .nav-tabs {
display: inline-table;
max-height: 500px;
min-height: 44px;
overflow-y: auto;
border: 1px solid #ddd;
border-radius: 4px;
}
.tabset-dropdown > .nav-tabs > li.active:before, .tabset-dropdown > .nav-tabs.nav-tabs-open:before {
content: "\e259";
font-family: 'Glyphicons Halflings';
display: inline-block;
padding: 10px;
border-right: 1px solid #ddd;
}
.tabset-dropdown > .nav-tabs.nav-tabs-open > li.active:before {
content: "\e258";
font-family: 'Glyphicons Halflings';
border: none;
}
.tabset-dropdown > .nav-tabs > li.active {
display: block;
}
.tabset-dropdown > .nav-tabs > li > a,
.tabset-dropdown > .nav-tabs > li > a:focus,
.tabset-dropdown > .nav-tabs > li > a:hover {
border: none;
display: inline-block;
border-radius: 4px;
background-color: transparent;
}
.tabset-dropdown > .nav-tabs.nav-tabs-open > li {
display: block;
float: none;
}
.tabset-dropdown > .nav-tabs > li {
display: none;
}
</style>
<!-- code folding -->
</head>
<body>
<div class="container-fluid main-container">
<nav>
<div class="navbar navbar-default navbar-fixed-top" role="navigation">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href=".">analyse-R</a>
</div>
<div id="navbar" class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li class="dropdown">
<a href="manipuler" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">Manipuler <span class="caret"></span></a>
<ul class="dropdown-menu multi-column columns-3" role="menu" id="menu_manipuler">
<div class="row">
<div class="col-sm-4">
<ul class="multi-column-dropdown">
<li class="dropdown-header">Prise en main</li>
<li><a href="presentation-et-philosophie.html">Présentation et Philosophie</a></li>
<li><a href="installation-de-R-et-RStudio.html">Installation de <strong>R</strong> et <strong>RStudio</strong></a></li>
<li><a href="premier-contact.html">Premier contact</a></li>
<li><a href="premier-travail-avec-les-donnees.html">Premier travail avec des données</a></li>
<li><a href="extensions.html">Extensions (installation, mise à jour)</a></li>
<li><a href="introduction-au-tidyverse.html">Introduction au <strong>tidyverse</strong></a></li>
<li><a href="vecteurs-indexation-et-assignation.html">Vecteurs, indexation et assignation</a></li>
<li><a href="listes-et-tableaux-de-donnees.html">Listes et Tableaux de données</a></li>
<li><a href="facteurs-et-vecteurs-labellises.html">Facteurs et vecteurs labellisés</a></li>
<li><a href="organiser-ses-fichiers.html">Organiser ses fichiers</a></li>
<li><a href="import-de-donnees.html">Import de données</a></li>
<li><a href="ou-trouver-de-l-aide.html">Où trouver de l'aide ?</a></li>
</ul>
</div>
<div class="col-sm-4">
<ul class="multi-column-dropdown">
<li class="dropdown-header">Manipulation de données</li>
<li><a href="visualiser-ses-donnees.html">Visualiser ses données</a></li>
<li><a href="recodage.html">Recodage de variables</a></li>
<li><a href="manipuler-les-donnees-avec-dplyr.html">Manipuler les données avec <strong>dplyr</strong></a></li>
<li><a href="manipulations-avancees-avec-data-table.html">Manipulations avancées avec <strong>data.table</strong></a></li>
<li><a href="tris.html">Tris</a></li>
<li><a href="sous-ensembles.html">Sous-ensembles</a></li>
<li><a href="fusion-de-tables.html">Fusion de tables</a></li>
<li><a href="gestion-des-dates.html">Gestion des dates</a></li>
<li><a href="fonctions-a-fenetre.html">Fonctions à fenêtre</a></li>
<li><a href="manipuler-du-texte.html">Manipuler du texte avec <strong>stringr</strong></a></li>
<li><a href="reorganiser-ses-donnees-avec-tidyr.html">Réorganiser ses données avec <strong>tidyr</strong></a></li>
<!--<li><a href="scraping.html.old">Scraping</a></li>-->
</ul>
</div>
<div class="col-sm-4">
<ul class="multi-column-dropdown">
<li class="dropdown-header">Exporter</li>
<li><a href="export-de-donnees.html">Export de données</a></li>
<li><a href="export-de-graphiques.html">Export de graphiques</a></li>
</ul>
</div>
</div>
</ul>
</li>
<li class="dropdown">
<a href="analyser" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">Analyser <span class="caret"></span></a>
<ul class="dropdown-menu multi-column columns-3" role="menu" id="menu_analyser">
<div class="row">
<div class="col-sm-4">
<ul class="multi-column-dropdown">
<li class="dropdown-header">Statistiques introductives</li>
<li><a href="statistique-univariee.html">Statistique univariée</a></li>
<li><a href="statistique-bivariee.html">Statistique bivariée</a></li>
<li><a href="intro-ggplot2.html">Introduction à <strong>ggplot2</strong>, la grammaire des graphiques</a></li>
<li><a href="graphiques-bivaries-ggplot2.html">Graphiques univariés et bivariés avec <strong>ggplot2</strong></a></li>
<li><a href="donnees-ponderees.html">Données pondérées</a></li>
</ul>
</div>
<div class="col-sm-4">
<ul class="multi-column-dropdown">
<li class="dropdown-header">Statistiques intermédiaires</li>
<li><a href="intervalles-de-confiance.html">Intervalles de confiance</a></li>
<li><a href="comparaisons-moyennes-et-proportions.html">Comparaisons (moyennes et proportions)</a></li>
<li><a href="definir-un-plan-d-echantillonnage-complexe.html">Définir un plan d'échantillonnage complexe avec <strong>survey</strong></a></li>
<li><a href="regression-lineaire.html">Régression linéaire</a></li>
<li><a href="regression-logistique.html">Régression logistique binaire, multinomiale et ordinale</a></li>
<li><a href="analyse-des-correspondances-multiples.html">Analyse des correspondances multiples (ACM)</a></li>
<li><a href="classification-ascendante-hierarchique.html">Classification ascendante hiérarchique (CAH)</a></li>
</ul>
</div>
<div class="col-sm-4">
<ul class="multi-column-dropdown">
<li class="dropdown-header">Statistiques avancées</li>
<li><a href="gtsummary.html">Tableaux statistiques avancés avec <strong>gtsummary</strong></a></li>
<li><a href="effets-d-interaction.html">Effets d'interaction dans un modèle</a></li>
<li><a href="multicolinearite.html">Multicolinéarité dans la régression</a></li>
<li><a href="modeles.html">Quel type de modèles choisir ?</a></li>
<li><a href="analyse-de-survie.html">Analyse de survie</a></li>
<li><a href="analyse-de-sequences.html">Analyse de séquences</a></li>
<!--<li><a href="modeles-a-effets-aleatoires.html">Modèles à effets aléatoires (modèles mixtes et GEE)</a></li>-->
<li><a href="trajectoires-de-soins.html">Trajectoires de soins : un exemple de données longitudinales</a></li>
<li><a href="analyse-de-reseaux.html">Analyse de réseaux</a></li>
<li><a href="analyse-spatiale.html">Analyse spatiale</a></li>
<li><a href="analyse-textuelle.html">Analyse textuelle</a></li>
</ul>
</div>
</div>
</ul>
</li>
<li class="dropdown">
<a href="approfondir" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">Approfondir <span class="caret"></span></a>
<ul class="dropdown-menu multi-column columns-3" role="menu" id="menu_approfondir">
<div class="row">
<div class="col-sm-4">
<ul class="multi-column-dropdown">
<li class="dropdown-header">Graphiques</li>
<li><a href="ggplot2.html"><strong>ggplot2</strong> et la grammaire des graphiques</a></li>
<li><a href="etendre-ggplot2.html">Étendre <strong>ggplot2</strong></a></li>
<li><a href="combiner-plusieurs-graphiques.html">Combiner plusieurs graphiques</a></li>
<li><a href="exemples-graphiques-avances.html">Exemples de graphiques avancés</a></li>
<li><a href="graphiques-interactifs.html">Graphiques interactifs</a></li>
<li><a href="lattice-graphiques-et-formules.html"><strong>lattice</strong> : graphiques et formules</a></li>
<li><a href="cartes.html">Cartes</a></li>
<li><a href="autres-extensions-graphiques.html">Autres extensions graphiques</a></li>
</ul>
</div>
<div class="col-sm-4">
<ul class="multi-column-dropdown">
<li class="dropdown-header">Programmation</li>
<li><a href="conditions-et-comparaisons.html">Conditions et comparaisons</a></li>
<li><a href="formules.html">Formules</a></li>
<li><a href="structures-conditionnelles.html">Structures conditionnelles</a></li>
<li><a href="vectorisation.html">Vectorisation (dont <strong>purrr</strong>)</a></li>
<li><a href="expressions-regulieres.html">Expressions régulières</a></li>
<!--<li class="dev"><a href="ecrire-ses-propres-fonctions.html">Écrire ses propres fonctions</a></li>-->
<li><a href="rmarkdown-les-rapports-automatises.html"><strong>R Markdown</strong> : les rapports automatisés</a></li>
</ul>
</div>
<div class="col-sm-4">
<ul class="multi-column-dropdown">
<li class="dropdown-header">Divers</li>
<li><a href="formater-nombres.html">Mettre en forme des nombres avec <strong>scales</strong></a></li>
<li><a href="couleurs.html">Couleurs et Palettes</a></li>
<li><a href="annotations-mathematiques.html">Annotations mathématiques</a></li>
<li><a href="calculer-un-age.html">Calculer un âge</a></li>
<li><a href="diagramme-de-lexis.html">Diagramme de Lexis</a></li>
</ul>
</div>
</div>
</ul>
</li>
<li class="dropdown">
<a href="index" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">Index <span class="caret"></span></a>
<ul class="dropdown-menu" role="menu" id="menu_naviguer">
<li><a href="index-des-concepts.html">Index des concepts</a></li>
<li><a href="index-des-fonctions.html">Index des fonctions</a></li>
<li><a href="index-des-extensions.html">Index des extensions</a></li>
</ul>
</li>
<li><a href="analyse-R.pdf">PDF</a></li>
<li><a href="https://larmarange.github.io/guide-R/">guide-R</a></li>
<li><a href="https://larmarange.github.io/webin-R/">webin-R</a></li>
<li><a href="https://www.youtube.com/c/webinR"><i class="fa fa-youtube" aria-hidden="true"></i></a></li>
<!--<li><a href="https://github.com/larmarange/analyse-R">GitHub</a></li>-->
</ul>
<form id="rechercher" class="navbar-form navbar-right" role="search" style="padding-top: 5px;" method="get" action="https://duckduckgo.com/">
<div class="form-group">
<input name="q" type="text" class="form-control input-sm" placeholder="Rechercher">
</div>
<button type="submit" class="btn btn-default btn-sm" name="Rechercher">
<span class="glyphicon glyphicon-search" aria-hidden="true"></span>
</button>
</form>
</div><!--/.nav-collapse -->
</div><!--/.container -->
</div><!--/.navbar -->
</nav>
<div class="row">
<div class="visible-lg">
<a href="https://github.com/larmarange/analyse-R"><img style="position: absolute; top: 60px; left: 40px; border: 0;" src="images/fork_me.png" alt="Contribuer sur GitHub"></a>
</div>
<div class="col-sm-9" role="main">
<article>
<div id="header">
<h1 class="title toc-ignore">Mettre en forme des nombres avec scales</h1>
</div>
<div id="TOC">
<ul>
<li><a href="#number-ou-label_number" id="toc-number-ou-label_number">number() ou label_number() ?</a></li>
<li><a href="#label_number" id="toc-label_number">label_number()</a></li>
<li><a href="#label_comma" id="toc-label_comma">label_comma()</a></li>
<li><a href="#label_percent" id="toc-label_percent">label_percent()</a></li>
<li><a href="#label_dollar" id="toc-label_dollar">label_dollar()</a></li>
<li><a href="#label_pvalue-style_pvalue-signif_stars" id="toc-label_pvalue-style_pvalue-signif_stars">label_pvalue(), style_pvalue() & signif_stars()</a></li>
<li><a href="#label_number_si" id="toc-label_number_si">label_number_si()</a></li>
<li><a href="#label_scientific" id="toc-label_scientific">label_scientific()</a></li>
<li><a href="#label_bytes" id="toc-label_bytes">label_bytes()</a></li>
<li><a href="#label_ordinal" id="toc-label_ordinal">label_ordinal()</a></li>
<li><a href="#label_date-label_date_short-label_time" id="toc-label_date-label_date_short-label_time">label_date(), label_date_short() & label_time()</a></li>
<li><a href="#label_wrap" id="toc-label_wrap">label_wrap()</a></li>
</ul>
</div>
<div class="guide-R">
<p>Une version actualisée de ce chapitre est disponible sur <strong>guide-R</strong> : <a href="https://larmarange.github.io/guide-R/manipulation/formater-nombre.html">Mettre en forme des nombres</a></p>
</div>
<div class="webin-R">
<p>Ce chapitre est évoqué dans le webin-R #09 (Graphiques uni- et bivariés avec ggplot2) sur <a href="https://youtu.be/73xvKXSnV1I">YouTube</a>.</p>
</div>
<p>Il existe de nombreuses fonctions pour mettre en forme des nombres sous <strong>R</strong>. La fonction de base est <code data-pkg="base">format</code>. Plusieurs packages proposent des variations pour rendre cette mise en forme plus facile. Cependant, s’il y a une extension à retenir, c’est l’extension <code class="pkg">scales</code>.</p>
<div id="number-ou-label_number" class="section level2 hasAnchor">
<h2 class="hasAnchor">number() ou label_number() ?<a href="#number-ou-label_number" class="anchor-section" aria-label="Anchor link to header"></a></h2>
<p>Les deux fonctions de base sont <code data-pkg="scales">number</code> et <code data-pkg="scales">label_number</code>. Elles ont l’air très similaires et partagent un grand nombre de paramètres en commun. La différence est que <code data-pkg="scales">number</code> a besoin d’un vecteur numérique en entrée qu’elle va mettre en forme, tandis que que <code data-pkg="scales">label_number</code> renvoie une fonction que l’on pourra ensuite appliquer à un vecteur numérique.</p>
<div class="sourceCode" id="cb1"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb1-1"><a href="#cb1-1" tabindex="-1"></a><span class="fu">library</span>(scales)</span>
<span id="cb1-2"><a href="#cb1-2" tabindex="-1"></a>x <span class="ot"><-</span> <span class="fu">c</span>(<span class="fl">0.0023</span>, .<span class="dv">123</span>, <span class="fl">4.567</span>, <span class="fl">874.44</span>, <span class="dv">8957845</span>)</span>
<span id="cb1-3"><a href="#cb1-3" tabindex="-1"></a><span class="fu">number</span>(x)</span></code></pre></div>
<pre><code>[1] "0.00" "0.12" "4.57"
[4] "874.44" "8 957 845.00"</code></pre>
<div class="sourceCode" id="cb3"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb3-1"><a href="#cb3-1" tabindex="-1"></a>f <span class="ot"><-</span> <span class="fu">label_number</span>()</span>
<span id="cb3-2"><a href="#cb3-2" tabindex="-1"></a><span class="fu">f</span>(x)</span></code></pre></div>
<pre><code>[1] "0.00" "0.12" "4.57"
[4] "874.44" "8 957 845.00"</code></pre>
<div class="sourceCode" id="cb5"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb5-1"><a href="#cb5-1" tabindex="-1"></a><span class="fu">label_number</span>()(x)</span></code></pre></div>
<pre><code>[1] "0.00" "0.12" "4.57"
[4] "874.44" "8 957 845.00"</code></pre>
<p>Dans de nombreux cas de figure (par exemple pour un graphique <code class="pkg">ggplot2</code> ou un tableau <code class="pkg">gtsummary</code>), il sera demandé de fournir une fonction, auquel cas on aura recours aux fonctions de <code class="pkg">scales</code> préfixées par <code>label_*()</code>.</p>
</div>
<div id="label_number" class="section level2 hasAnchor">
<h2 class="hasAnchor">label_number()<a href="#label_number" class="anchor-section" aria-label="Anchor link to header"></a></h2>
<p><code data-pkg="scales">label_number</code> est la fonction de base de mise en forme de nombres dans <code class="pkg">scales</code>, une majorité des autres fonctions faisant appel à <code data-pkg="scales">label_number</code> et partageant les mêmes arguments.</p>
<p>Le paramètre <code>accurary</code> permets de définir le niveau d’arrondi à utiliser. Par exemple, <code>.1</code> pour afficher une seule décimale. Il est aussi possible d’indiquer un nombre qui n’est pas une puissance de 10 (par exemple <code>.25</code>). Si on n’indique rien (<code>NULL</code>), alors <code data-pkg="scales">label_number</code> essaiera de deviner un nombre de décimales pertinent en fonction des valeurs du vecteur de nombres à mettre en forme.</p>
<div class="sourceCode" id="cb7"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb7-1"><a href="#cb7-1" tabindex="-1"></a><span class="fu">label_number</span>(<span class="at">accuracy =</span> <span class="cn">NULL</span>)(x)</span></code></pre></div>
<pre><code>[1] "0.00" "0.12" "4.57"
[4] "874.44" "8 957 845.00"</code></pre>
<div class="sourceCode" id="cb9"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb9-1"><a href="#cb9-1" tabindex="-1"></a><span class="fu">label_number</span>(<span class="at">accuracy =</span> .<span class="dv">1</span>)(x)</span></code></pre></div>
<pre><code>[1] "0.0" "0.1" "4.6" "874.4"
[5] "8 957 845.0"</code></pre>
<div class="sourceCode" id="cb11"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb11-1"><a href="#cb11-1" tabindex="-1"></a><span class="fu">label_number</span>(<span class="at">accuracy =</span> .<span class="dv">25</span>)(x)</span></code></pre></div>
<pre><code>[1] "0.0" "0.0" "4.5" "874.5"
[5] "8 957 845.0"</code></pre>
<div class="sourceCode" id="cb13"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb13-1"><a href="#cb13-1" tabindex="-1"></a><span class="fu">label_number</span>(<span class="at">accuracy =</span> <span class="dv">10</span>)(x)</span></code></pre></div>
<pre><code>[1] "0" "0" "0" "870"
[5] "8 957 840"</code></pre>
<p>L’option <code>scale</code> permets d’indiquer un facteur multiplicatif à appliquer avant de mettre en forme. On utilisera le plus souvent les options <code>prefix</code> et <code>suffix</code> en même temps pour indiquer les unités.</p>
<div class="sourceCode" id="cb15"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb15-1"><a href="#cb15-1" tabindex="-1"></a><span class="fu">label_number</span>(<span class="at">scale =</span> <span class="dv">100</span>, <span class="at">suffix =</span> <span class="st">"%"</span>)(x) <span class="co"># pour cent</span></span></code></pre></div>
<pre><code>[1] "0%" "12%" "457%"
[4] "87 444%" "895 784 500%"</code></pre>
<div class="sourceCode" id="cb17"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb17-1"><a href="#cb17-1" tabindex="-1"></a><span class="fu">label_number</span>(<span class="at">scale =</span> <span class="dv">1000</span>, <span class="at">suffix =</span> <span class="st">"\u2030"</span>)(x) <span class="co"># pour mille</span></span></code></pre></div>
<pre><code>[1] "2‰" "123‰" "4 567‰"
[4] "874 440‰" "8 957 845 000‰"</code></pre>
<div class="sourceCode" id="cb19"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb19-1"><a href="#cb19-1" tabindex="-1"></a><span class="fu">label_number</span>(<span class="at">scale =</span> .<span class="dv">001</span>, <span class="at">suffix =</span> <span class="st">" milliers"</span>, <span class="at">accuracy =</span> .<span class="dv">1</span>)(x)</span></code></pre></div>
<pre><code>[1] "0.0 milliers" "0.0 milliers" "0.0 milliers"
[4] "0.9 milliers" "8 957.8 milliers"</code></pre>
<p>Les arguments <code>decimal.mark</code> et <code>big.mark</code> permettent de définir, respectivement, le séparateur de décimale et le séparateur de milliers. Ainsi, pour afficher des nombres <q>à la française</q> (virgule pour les décimales, espace pour les milliers) :</p>
<div class="sourceCode" id="cb21"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb21-1"><a href="#cb21-1" tabindex="-1"></a><span class="fu">label_number</span>(<span class="at">decimal.mark =</span> <span class="st">","</span>, <span class="at">big.mark =</span> <span class="st">" "</span>)(x)</span></code></pre></div>
<pre><code>[1] "0,00" "0,12" "4,57"
[4] "874,44" "8 957 845,00"</code></pre>
<p>Note : il est possible d’utiliser <code>small.interval</code> et <code>small.mark</code> pour ajouter des séparateurs parmi les décimales.</p>
<div class="sourceCode" id="cb23"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb23-1"><a href="#cb23-1" tabindex="-1"></a><span class="fu">label_number</span>(<span class="at">accuracy =</span> <span class="dv">10</span><span class="sc">^-</span><span class="dv">9</span>, <span class="at">small.mark =</span> <span class="st">"|"</span>, <span class="at">small.interval =</span> <span class="dv">3</span>)(x)</span></code></pre></div>
<pre><code>[1] "0.002|300|000" "0.123|000|000"
[3] "4.567|000|000" "874.440|000|000"
[5] "8 957 845.000|000|000"</code></pre>
</div>
<div id="label_comma" class="section level2 hasAnchor">
<h2 class="hasAnchor">label_comma()<a href="#label_comma" class="anchor-section" aria-label="Anchor link to header"></a></h2>
<p><code data-pkg="scales">label_comma</code> (et <code data-pkg="scales">comma</code>) est une variante de <code data-pkg="scales">label_number</code> qui, par défaut, affiche les nombres à l’américaine, avec une virgule comme séparateur de milliers.</p>
<div class="sourceCode" id="cb25"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb25-1"><a href="#cb25-1" tabindex="-1"></a><span class="fu">label_comma</span>()(x)</span></code></pre></div>
<pre><code>[1] "0.00" "0.12" "4.57"
[4] "874.44" "8,957,845.00"</code></pre>
</div>
<div id="label_percent" class="section level2 hasAnchor">
<h2 class="hasAnchor">label_percent()<a href="#label_percent" class="anchor-section" aria-label="Anchor link to header"></a></h2>
<p><code data-pkg="scales">label_percent</code> (et <code data-pkg="scales">percent</code>) est une variante de <code data-pkg="scales">label_number</code> qui affiche les nombres sous formes de pourcentages (<code>scale = 100, suffix = "%"</code>).</p>
<div class="sourceCode" id="cb27"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb27-1"><a href="#cb27-1" tabindex="-1"></a><span class="fu">label_percent</span>()(x)</span></code></pre></div>
<pre><code>[1] "0%" "12%" "457%"
[4] "87 444%" "895 784 500%"</code></pre>
</div>
<div id="label_dollar" class="section level2 hasAnchor">
<h2 class="hasAnchor">label_dollar()<a href="#label_dollar" class="anchor-section" aria-label="Anchor link to header"></a></h2>
<p><code data-pkg="scales">label_dollar</code> est adapté à l’affichage des valeurs monétaires.</p>
<div class="sourceCode" id="cb29"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb29-1"><a href="#cb29-1" tabindex="-1"></a><span class="fu">label_dollar</span>()(x)</span></code></pre></div>
<pre><code>[1] "$0" "$0" "$5" "$874"
[5] "$8,957,845"</code></pre>
<div class="sourceCode" id="cb31"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb31-1"><a href="#cb31-1" tabindex="-1"></a><span class="fu">label_dollar</span>(<span class="at">prefix =</span> <span class="st">""</span>, <span class="at">suffix =</span> <span class="st">" €"</span>, <span class="at">accuracy =</span> .<span class="dv">01</span>, <span class="at">big.mark =</span> <span class="st">" "</span>)(x)</span></code></pre></div>
<pre><code>[1] "0.00 €" "0.12 €" "4.57 €"
[4] "874.44 €" "8 957 845.00 €"</code></pre>
<p>L’option <code>negative_parens</code> permet d’afficher les valeurs négatives avec des parenthèses, convention utilisée dans certaines disciplines.</p>
<div class="sourceCode" id="cb33"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb33-1"><a href="#cb33-1" tabindex="-1"></a><span class="fu">label_dollar</span>()(<span class="fu">c</span>(<span class="fl">12.5</span>, <span class="sc">-</span><span class="dv">4</span>, <span class="dv">21</span>, <span class="sc">-</span><span class="fl">56.36</span>))</span></code></pre></div>
<pre><code>[1] "$12.50" "-$4.00" "$21.00" "-$56.36"</code></pre>
<div class="sourceCode" id="cb35"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb35-1"><a href="#cb35-1" tabindex="-1"></a><span class="fu">label_dollar</span>(<span class="at">negative_parens =</span> <span class="cn">TRUE</span>)(<span class="fu">c</span>(<span class="fl">12.5</span>, <span class="sc">-</span><span class="dv">4</span>, <span class="dv">21</span>, <span class="sc">-</span><span class="fl">56.36</span>))</span></code></pre></div>
<pre><code>Warning: The `negative_parens` argument of `dollar()` is deprecated
as of scales 1.2.0.
ℹ Please use the `style_negative` argument instead.
ℹ The deprecated feature was likely used in the scales
package.
Please report the issue at
<]8;;https://github.com/r-lib/scales/issueshttps://github.com/r-lib/scales/issues]8;;>.</code></pre>
<pre><code>[1] "$12.50" "($4.00)" "$21.00" "($56.36)"</code></pre>
</div>
<div id="label_pvalue-style_pvalue-signif_stars" class="section level2 hasAnchor">
<h2 class="hasAnchor">label_pvalue(), style_pvalue() & signif_stars()<a href="#label_pvalue-style_pvalue-signif_stars" class="anchor-section" aria-label="Anchor link to header"></a></h2>
<p><code data-pkg="scales">label_pvalue</code> est adapté pour la mise en forme de p-valeurs.</p>
<div class="sourceCode" id="cb38"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb38-1"><a href="#cb38-1" tabindex="-1"></a><span class="fu">label_pvalue</span>()(<span class="fu">c</span>(<span class="fl">0.000001</span>, <span class="fl">0.023</span>, <span class="fl">0.098</span>, <span class="fl">0.60</span>, <span class="fl">0.9998</span>))</span></code></pre></div>
<pre><code>[1] "<0.001" "0.023" "0.098" "0.600" ">0.999"</code></pre>
<div class="sourceCode" id="cb40"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb40-1"><a href="#cb40-1" tabindex="-1"></a><span class="fu">label_pvalue</span>(<span class="at">accuracy =</span> .<span class="dv">01</span>, <span class="at">add_p =</span> <span class="cn">TRUE</span>)(<span class="fu">c</span>(<span class="fl">0.000001</span>, <span class="fl">0.023</span>, <span class="fl">0.098</span>, <span class="fl">0.60</span>))</span></code></pre></div>
<pre><code>[1] "p<0.01" "p=0.02" "p=0.10" "p=0.60"</code></pre>
<p>À noter, la fonction <code data-pkg="gtsummary">style_pvalue</code> de l’extension <code class="pkg">gtsummary</code> ayant à peu près le même objectif mais adaptant le nombre de décimales en fonction de la p-valeur.</p>
<div class="sourceCode" id="cb42"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb42-1"><a href="#cb42-1" tabindex="-1"></a>gtsummary<span class="sc">::</span><span class="fu">style_pvalue</span>(<span class="fu">c</span>(<span class="fl">0.000001</span>, <span class="fl">0.023</span>, <span class="fl">0.098</span>, <span class="fl">0.60</span>, <span class="fl">0.9998</span>))</span></code></pre></div>
<pre><code>[1] "<0,001" "0,023" "0,10" "0,6" ">0,9" </code></pre>
<p>La fonction <code data-pkg="GGally">signif_stars</code> de <code class="pkg">GGally</code> permet quant à elle d’afficher les p-valeurs sous forme d’étoiles de significativité, Par défaut, trois astérisques si p < 0.001, deux si p < 0.01, une si p < 0.05 et un point si p < 0.10. Les valeurs sont bien sur paramétrables.</p>
<div class="sourceCode" id="cb44"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb44-1"><a href="#cb44-1" tabindex="-1"></a>p <span class="ot"><-</span> <span class="fu">c</span>(<span class="fl">0.5</span>, <span class="fl">0.1</span>, <span class="fl">0.05</span>, <span class="fl">0.01</span>, <span class="fl">0.001</span>)</span>
<span id="cb44-2"><a href="#cb44-2" tabindex="-1"></a>GGally<span class="sc">::</span><span class="fu">signif_stars</span>(p)</span></code></pre></div>
<pre><code>[1] "" "." "*" "**" "***"</code></pre>
<div class="sourceCode" id="cb46"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb46-1"><a href="#cb46-1" tabindex="-1"></a>GGally<span class="sc">::</span><span class="fu">signif_stars</span>(p, <span class="at">one =</span> .<span class="dv">15</span>, <span class="at">point =</span> <span class="cn">NULL</span>)</span></code></pre></div>
<pre><code>[1] "" "*" "*" "**" "***"</code></pre>
</div>
<div id="label_number_si" class="section level2 hasAnchor">
<h2 class="hasAnchor">label_number_si()<a href="#label_number_si" class="anchor-section" aria-label="Anchor link to header"></a></h2>
<p><code data-pkg="scales">label_number_si</code> cherche le <a href="https://fr.wikipedia.org/wiki/Pr%C3%A9fixes_du_Syst%C3%A8me_international_d%27unit%C3%A9s">préfixe du Système international d’unités</a> le plus proche et arrondi chaque valeur en fonction, en ajoutant la précision correspondante.</p>
<div class="sourceCode" id="cb48"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb48-1"><a href="#cb48-1" tabindex="-1"></a><span class="fu">label_number_si</span>(<span class="at">unit =</span> <span class="st">"g"</span>)(<span class="fu">c</span>(.<span class="dv">00000145</span>, .<span class="dv">0034</span>, <span class="dv">5</span>, <span class="dv">12478</span>, <span class="dv">14569787</span>))</span></code></pre></div>
<pre><code>Warning: `label_number_si()` was deprecated in scales 1.2.0.
ℹ Please use the `scale_cut` argument of `label_number()`
instead.</code></pre>
<pre><code>[1] "0.0000 g" "0.0034 g" "5.0000 g" "12 Kg" "15 Mg" </code></pre>
</div>
<div id="label_scientific" class="section level2 hasAnchor">
<h2 class="hasAnchor">label_scientific()<a href="#label_scientific" class="anchor-section" aria-label="Anchor link to header"></a></h2>
<p><code data-pkg="scales">label_scientific</code> affiche les nombres dans un format scientifique (avec des puissances de 10).</p>
<div class="sourceCode" id="cb51"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb51-1"><a href="#cb51-1" tabindex="-1"></a><span class="fu">label_scientific</span>(<span class="at">unit =</span> <span class="st">"g"</span>)(<span class="fu">c</span>(.<span class="dv">00000145</span>, .<span class="dv">0034</span>, <span class="dv">5</span>, <span class="dv">12478</span>, <span class="dv">14569787</span>))</span></code></pre></div>
<pre><code>[1] "1.45e-06" "3.40e-03" "5.00e+00" "1.25e+04" "1.46e+07"</code></pre>
</div>
<div id="label_bytes" class="section level2 hasAnchor">
<h2 class="hasAnchor">label_bytes()<a href="#label_bytes" class="anchor-section" aria-label="Anchor link to header"></a></h2>
<p><code data-pkg="scales">label_bytes</code> mets en forme des tailles exprimées en octets, utilisant au besoin des multiples de 1024.</p>
<div class="sourceCode" id="cb53"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb53-1"><a href="#cb53-1" tabindex="-1"></a>b <span class="ot"><-</span> <span class="fu">c</span>(<span class="dv">478</span>, <span class="dv">1235468</span>, <span class="dv">546578944897</span>)</span>
<span id="cb53-2"><a href="#cb53-2" tabindex="-1"></a><span class="fu">label_bytes</span>()(b)</span></code></pre></div>
<pre><code>[1] "478 B" "1 MB" "547 GB"</code></pre>
<div class="sourceCode" id="cb55"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb55-1"><a href="#cb55-1" tabindex="-1"></a><span class="fu">label_bytes</span>(<span class="at">units =</span> <span class="st">"auto_binary"</span>)(b)</span></code></pre></div>
<pre><code>[1] "478 iB" "1 MiB" "509 GiB"</code></pre>
</div>
<div id="label_ordinal" class="section level2 hasAnchor">
<h2 class="hasAnchor">label_ordinal()<a href="#label_ordinal" class="anchor-section" aria-label="Anchor link to header"></a></h2>
<p><code data-pkg="scales">label_bytes</code> permets d’afficher des rangs ou nombres ordinaux. Plusieurs langues sont disponibles.</p>
<div class="sourceCode" id="cb57"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb57-1"><a href="#cb57-1" tabindex="-1"></a><span class="fu">label_ordinal</span>()(<span class="dv">1</span><span class="sc">:</span><span class="dv">5</span>)</span></code></pre></div>
<pre><code>[1] "1st" "2nd" "3rd" "4th" "5th"</code></pre>
<div class="sourceCode" id="cb59"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb59-1"><a href="#cb59-1" tabindex="-1"></a><span class="fu">label_ordinal</span>(<span class="at">rules =</span> <span class="fu">ordinal_french</span>())(<span class="dv">1</span><span class="sc">:</span><span class="dv">5</span>)</span></code></pre></div>
<pre><code>[1] "1er" "2e" "3e" "4e" "5e" </code></pre>
<div class="sourceCode" id="cb61"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb61-1"><a href="#cb61-1" tabindex="-1"></a><span class="fu">label_ordinal</span>(<span class="at">rules =</span> <span class="fu">ordinal_french</span>(<span class="at">gender =</span> <span class="st">"f"</span>, <span class="at">plural =</span> <span class="cn">TRUE</span>))(<span class="dv">1</span><span class="sc">:</span><span class="dv">5</span>)</span></code></pre></div>
<pre><code>[1] "1res" "2es" "3es" "4es" "5es" </code></pre>
</div>
<div id="label_date-label_date_short-label_time" class="section level2 hasAnchor">
<h2 class="hasAnchor">label_date(), label_date_short() & label_time()<a href="#label_date-label_date_short-label_time" class="anchor-section" aria-label="Anchor link to header"></a></h2>
<p><code data-pkg="scales">label_date</code>, <code data-pkg="scales">label_date_short</code> et <code data-pkg="scales">label_time</code> peuvent être utilisées pour la mise en forme de dates.</p>
<div class="sourceCode" id="cb63"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb63-1"><a href="#cb63-1" tabindex="-1"></a><span class="fu">label_date</span>()(<span class="fu">as.Date</span>(<span class="st">"2020-02-14"</span>))</span></code></pre></div>
<pre><code>[1] "2020-02-14"</code></pre>
<div class="sourceCode" id="cb65"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb65-1"><a href="#cb65-1" tabindex="-1"></a><span class="fu">label_date</span>(<span class="at">format =</span> <span class="st">"%d/%m/%Y"</span>)(<span class="fu">as.Date</span>(<span class="st">"2020-02-14"</span>))</span></code></pre></div>
<pre><code>[1] "14/02/2020"</code></pre>
<div class="sourceCode" id="cb67"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb67-1"><a href="#cb67-1" tabindex="-1"></a><span class="fu">label_date_short</span>()(<span class="fu">as.Date</span>(<span class="st">"2020-02-14"</span>))</span></code></pre></div>
<pre><code>[1] "14\nfévr.\n2020"</code></pre>
<p>La mise en forme des dates est un peu complexe. Ne pas hésiter à consulter le fichier d’aide de la fonction <code data-pkg="base">strptime</code> pour plus d’informations.</p>
</div>
<div id="label_wrap" class="section level2 hasAnchor">
<h2 class="hasAnchor">label_wrap()<a href="#label_wrap" class="anchor-section" aria-label="Anchor link to header"></a></h2>
<p>La fonction <code data-pkg="scales">label_wrap</code> est un peu différente. Elle permets d’insérer des retours à la ligne (<code>\n</code>) dans des chaines de caractères. Elle tient compte des espaces pour identifier les mots et éviter ainsi des coupures au milieu d’un mot.</p>
<div class="sourceCode" id="cb69"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb69-1"><a href="#cb69-1" tabindex="-1"></a>x <span class="ot"><-</span> <span class="st">"Ceci est un texte assez long et que l'on souhaiterait afficher sur plusieurs lignes. Cependant, on souhaite éviter que des coupures apparaissent au milieu d'un mot."</span></span>
<span id="cb69-2"><a href="#cb69-2" tabindex="-1"></a><span class="fu">label_wrap</span>(<span class="dv">80</span>)(x)</span></code></pre></div>
<pre><code>[1] "Ceci est un texte assez long et que l'on souhaiterait afficher sur plusieurs\nlignes. Cependant, on souhaite éviter que des coupures apparaissent au milieu\nd'un mot."</code></pre>
<div class="sourceCode" id="cb71"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb71-1"><a href="#cb71-1" tabindex="-1"></a><span class="fu">label_wrap</span>(<span class="dv">80</span>)(x) <span class="sc">|></span> <span class="fu">message</span>()</span></code></pre></div>
<pre><code>Ceci est un texte assez long et que l'on souhaiterait afficher sur plusieurs
lignes. Cependant, on souhaite éviter que des coupures apparaissent au milieu
d'un mot.</code></pre>
<div class="sourceCode" id="cb73"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb73-1"><a href="#cb73-1" tabindex="-1"></a><span class="fu">label_wrap</span>(<span class="dv">40</span>)(x) <span class="sc">|></span> <span class="fu">message</span>()</span></code></pre></div>
<pre><code>Ceci est un texte assez long et que
l'on souhaiterait afficher sur
plusieurs lignes. Cependant, on
souhaite éviter que des coupures
apparaissent au milieu d'un mot.</code></pre>
</div>
</article>
</div>
<div class="col-sm-3" role="complementary">
<nav class="hidden-print hidden-xs" id="nav_sidebar">
</nav>
</div>
</div>
<script>
// manage active state of menu based on current page
$(document).ready(function () {
// active menu
href = window.location.pathname;
href = href.substr(href.lastIndexOf('/') + 1);
if (href=='') href = 'index.html';
$('a[href="' + href + '"]').parent().addClass('active');
$('a[href="' + href + '"]').parent().parents('li').addClass('active');
// élargir la page d'accueil
if (href=='index.html') $('.col-sm-9').attr('class','col-sm-12');
// rechercher
$("#rechercher").submit(function(event) {
$('input[name="q"]').val($('input[name="q"]').val() + ' site:larmarange.github.io/analyse-R');
});
// sidebar
$("#nav_sidebar").append($("#TOC").html());
$("#nav_sidebar ul").addClass("nav nav-stacked");
$("#TOC").addClass("visible-xs-block");
$('body').scrollspy({
target: '#nav_sidebar',
offset: 40
});
// Identifier les <pre> fermant
$('pre').next("*:not(pre)").prev().addClass('last'); // Dernier <pre> de chaque groupe contigu de <pre>
$('pre').parent().each(function (){
$(this).children('pre').last().addClass('last');
}); // Si <pre> est le dernier enfant de son parent
// Ajout liens rdocumentation et tooltip
$("code[data-pkg]").each(function( index ) {
pkg = $(this).attr('data-pkg');
if ($(this).attr('data-rdoc') !== undefined) {
rdocumentation = $(this).attr('data-rdoc');
} else {
rdocumentation = $(this).text();
}
fonction = $(this).text();
//$(this).wrap('<a href="http://www.rdocumentation.org/packages/'+pkg+'/functions/'+rdocumentation+'">');
$(this).wrap('<a href="http://rdrr.io/pkg/'+pkg+'/sym/'+rdocumentation+'">');
$(this).attr('data-toggle','tooltip');
$(this).attr('data-placement','top');
$(this).attr('title','package : ' + pkg);
$('[data-toggle="tooltip"]').tooltip();
});
$("code.pkg").each(function( index ) {
//$(this).wrap('<a href="http://www.rdocumentation.org/packages/'+$(this).text()+'">');
$(this).wrap('<a href="http://rdrr.io/pkg/'+$(this).text()+'">');
});
// Figures
$("figure").each(function( index ) {
if ($(this).children("figcaption").length > 0)
$(this).children("figcaption:first").prepend('<span class="figure-number">Figure '+(index+1)+'.</span> ');
else
$(this).append($("<figcaption>").append('<span class="figure-number">Figure '+(index+1)+'</span>'));
});
// Colorbox
/*----
jQuery('article div img').colorbox({
maxWidth: '90%',
maxHeight: '90%',
rel: 'figures',
current: "",
href: function(){
return $(this).attr('src');
},
title: function(){
return $(this).attr('alt');
}
});
jQuery('article div img').css('cursor', 'pointer');
jQuery('figure img').colorbox({
maxWidth: '90%',
maxHeight: '90%',
rel: 'figures',
current: "",
href: function(){
return $(this).attr('src');
},
title: function(){
return $(this).parent().children("figcaption").text();
}
});
jQuery('figure img').css('cursor', 'pointer');
-----*/
/* Clipboard --------------------------*/
function changeTooltipMessage(element, msg) {
var tooltipOriginalTitle=element.getAttribute('data-original-title');
element.setAttribute('data-original-title', msg);
$(element).tooltip('show');
element.setAttribute('data-original-title', tooltipOriginalTitle);
}
if(ClipboardJS.isSupported()) {
$(document).ready(function() {
var copyButton = "<button type='button' class='btn btn-primary btn-copy-ex' type = 'submit' title='Copier dans le presse-papier' aria-label='Copier dans le presse-papier' data-toggle='tooltip' data-placement='left auto' data-trigger='hover' data-clipboard-copy><i class='fa fa-copy'></i></button>";
$(".examples, div.sourceCode").addClass("hasCopyButton");
// Insert copy buttons:
$(copyButton).prependTo(".hasCopyButton");
// Initialize tooltips:
$('.btn-copy-ex').tooltip({container: 'body'});
// Initialize clipboard:
var clipboardBtnCopies = new ClipboardJS('[data-clipboard-copy]', {
text: function(trigger) {
return trigger.parentNode.textContent;
}
});
clipboardBtnCopies.on('success', function(e) {
changeTooltipMessage(e.trigger, 'Copié !');
e.clearSelection();
});
clipboardBtnCopies.on('error', function() {
changeTooltipMessage(e.trigger,'Appuyez sur Ctrl+C ou Command+C pour copier');
});
});
}
// Bigfoot
$(".footnotes > li").addClass("footnote");
$.bigfoot({
activateOnHover: true,
actionOriginalFN: "ignore"
});
});
</script>
<!-- Utterances comments
<script src="https://utteranc.es/client.js"
repo="larmarange/analyse-R"
issue-term="pathname"
label="commentaires"
theme="github-light"
crossorigin="anonymous"
async>
</script>
-->
<!-- Giscus comments -->
<script src="https://giscus.app/client.js"
data-repo="larmarange/analyse-R"
data-repo-id="MDEwOlJlcG9zaXRvcnkzNDk4NjY2Ng=="
data-category-id="DIC_kwDOAhXaqs4B_iH_"
data-mapping="pathname"
data-reactions-enabled="1"
data-emit-metadata="0"
data-theme="light"
data-lang="fr"
crossorigin="anonymous"
async>
</script>
<!-- disqus -->
<!---
<div class="row">
<div id="disqus_thread" class="col-sm-9" role="complementary"></div>
</div>
<script type="text/javascript">
/* * * CONFIGURATION VARIABLES: EDIT BEFORE PASTING INTO YOUR WEBPAGE * * */
var disqus_shortname = 'analyse-r'; // required: replace example with your forum shortname
/* * * DON'T EDIT BELOW THIS LINE * * */
(function() {
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
dsq.src = '//' + disqus_shortname + '.disqus.com/embed.js';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
})();
</script>
<noscript>Veuillez activer JavaScript pour voir les <a href="http://disqus.com/?ref_noscript">les commentaires gérés avec Disqus.</a></noscript>
<!--<a href="http://disqus.com" class="dsq-brlink">Les commentaires sont hébergés par <span class="logo-disqus">Disqus</span>.</a>-->
<footer>
<div class="row">
<div class="col-lg-12">
<p>Contenus sous licence <a href="https://creativecommons.org/licenses/by-nc-sa/3.0/fr/" rel="nofollow">Creative Commons Attribution - Pas d’utilisation commerciale - Partage dans les mêmes conditions</a>.<br />
Propulsé par <a href="http://www.r-project.org/" rel="nofollow">R</a>, </a><a href="http://www.rstudio.com/" rel="nofollow">RStudio</a>, <a href="http://rmarkdown.rstudio.com/" rel="nofollow">R Markdown</a>, <a href="http://yihui.name/knitr/" rel="nofollow">knitr</a>, <a href="http://pandoc.org/" rel="nofollow">pandoc</a> et <a href="http://www.princexml.com/" rel="nofollow">Prince XML</a>. Hébergé par <a href="https://github.com/" rel="nofollow">GitHub</a>.<br />
<a href="https://www.zenodo.org/badge/latestdoi/34986666"><img src="https://www.zenodo.org/badge/34986666.svg" alt="DOI"></a></p>
</div>
</div>
</footer>
</div>
<script>
// add bootstrap table styles to pandoc tables
function bootstrapStylePandocTables() {
$('tr.odd').parent('tbody').parent('table').addClass('table table-condensed');
}
$(document).ready(function () {
bootstrapStylePandocTables();
});
</script>
<!-- tabsets -->
<script>
$(document).ready(function () {
window.buildTabsets("TOC");
});
$(document).ready(function () {
$('.tabset-dropdown > .nav-tabs > li').click(function () {
$(this).parent().toggleClass('nav-tabs-open');
});
});
</script>
<!-- code folding -->
</body>
</html>