Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
mooc-rr
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
057f01494dacf75e464b303d8bcf6a6d
mooc-rr
Commits
cd5d310c
Commit
cd5d310c
authored
Sep 08, 2025
by
057f01494dacf75e464b303d8bcf6a6d
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fichier exercice Module 3
parent
288b6164
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
62 additions
and
0 deletions
+62
-0
Exercice_final_M3_TDB.R
module3/Exercice_final_M3_TDB.R
+62
-0
No files found.
module3/Exercice_final_M3_TDB.R
0 → 100644
View file @
cd5d310c
library
(
readr
)
library
(
ggplot2
)
WheatTDB
<-
read_csv
(
"module3/WheatTDB.csv"
)
#Consigne 1 :
#Composition des phraphique barplot et puis le tracé bleu puis la courbe rouge
ggplot
(
WheatTDB
,
aes
(
x
=
factor
(
Year
)))
+
geom_col
(
aes
(
y
=
Wheat
),
fill
=
"black"
)
+
geom_ribbon
(
aes
(
x
=
as.numeric
(
factor
(
Year
)),
ymin
=
0
,
ymax
=
Wages
),
fill
=
"blue"
,
alpha
=
0.3
)
+
geom_line
(
aes
(
y
=
Wages
,
group
=
1
),
color
=
"red"
)
#Consigne 2 :
#Supprimer les NA pour éviter l'erreur
wheat
<-
WheatTDB
$
Wheat
wages
<-
WheatTDB
$
Wages
years
<-
WheatTDB
$
Year
good
<-
!
is.na
(
wheat
)
&
!
is.na
(
wages
)
wheat
<-
wheat
[
good
]
wages
<-
wages
[
good
]
years
<-
years
[
good
]
#Barres noires = prix du blé
Barplot
<-
barplot
(
wheat
,
names.arg
=
years
,
col
=
"black"
,
ylim
=
c
(
0
,
max
(
wheat
,
na.rm
=
TRUE
)
*
1.2
),
ylab
=
"Prix du blé (shillings par quart de boisseau)"
)
#Ligne rouge = salaire avec axe droit
par
(
new
=
TRUE
)
plot
(
Barplot
,
wages
,
type
=
"l"
,
col
=
"red"
,
lwd
=
2
,
axes
=
FALSE
,
xlab
=
""
,
ylab
=
""
,
ylim
=
c
(
0
,
max
(
wages
,
na.rm
=
TRUE
)
*
1.2
))
axis
(
side
=
4
)
mtext
(
"Salaire (shillings par semaine)"
,
side
=
4
,
line
=
3
)
#Consigne 3 :
#Supprimer les NA
good
<-
!
is.na
(
WheatTDB
$
Wheat
)
&
!
is.na
(
WheatTDB
$
Wages
)
years
<-
WheatTDB
$
Year
[
good
]
wheat
<-
WheatTDB
$
Wheat
[
good
]
wages
<-
WheatTDB
$
Wages
[
good
]
#Pouvoir d'achat = combien de blé un ouvrier peut acheter
PouvoirAchat
<-
wages
/
wheat
#Graphique 1
plot
(
years
,
PouvoirAchat
,
type
=
"b"
,
pch
=
16
,
col
=
"blue"
,
xlab
=
"Année"
,
ylab
=
"Quantité de blé achetable (quart/semaine)"
,
main
=
"Pouvoir d'achat des ouvriers"
)
#Graphique 2
Barplot
<-
barplot
(
wheat
,
col
=
"black"
,
ylim
=
c
(
0
,
max
(
wheat
,
na.rm
=
TRUE
)
*
1.2
),
ylab
=
"Prix du blé (shillings/quarter)"
,
main
=
"Prix du blé et salaire"
)
#Superposition la ligne rouge = salaire
par
(
new
=
TRUE
)
plot
(
Barplot
,
wages
,
type
=
"b"
,
col
=
"red"
,
pch
=
16
,
axes
=
FALSE
,
xlab
=
""
,
ylab
=
""
,
ylim
=
c
(
0
,
max
(
wages
,
na.rm
=
TRUE
)
*
1.2
))
axis
(
side
=
4
)
mtext
(
"Salaire (shillings/week)"
,
side
=
4
,
line
=
3
)
#Progression du temps
text
(
Barplot
,
wages
,
labels
=
1
:
length
(
wages
),
pos
=
3
,
cex
=
0.7
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment