Radu-Ionel Toma
12/22/2020
This document present the Peer-graded Assignment: R Markdown Presentation & Plotly for the course “Developing Data Products” from Coursera.
The assignments requirements are the following:
For this assignment we will analyze the results at the National Assessment of 8th Grade Students (EN VIII) in Romania. The EN VIII is the way of summation external assessment of the skills acquired during lower secondary education.
More information can be found on the Romanian’ Ministry of Education and Research website.
Dataset used on this study is published on DATA.GOV.RO.
The dataset used for this study will be downloaded on local computer, in the working directory.
# load packages
library(readxl)
library(dplyr)
library(plotly)
# load the dataset
fileURL <- "https://data.gov.ro/dataset/a5bae3fe-d1e6-4de1-8667-f2a0a904d2ad/resource/82154f44-b580-4773-a9d7-ca6c5bc270af/download/evnat_date-deschise_2020.xlsx"
fileName <- "evnat_date-deschise_2020.xlsx"
# Checking if file already exists and download it.
if (!file.exists(fileName)) {
download.file(fileURL, fileName, method = "curl")
}
df1 <- read_excel(fileName)
head(df1, 5)## # A tibble: 5 x 21
## `COD UNIC CANDI~ SEX MEDIU `COD SIIIR` `STATUS ROMANA` `STATUS LIMBA M~
## <dbl> <chr> <chr> <chr> <chr> <chr>
## 1 10525707 F RURAL 3761104457 PREZENT -
## 2 10324065 F RURAL 3761107591 PREZENT -
## 3 10324238 F RURAL 3761107591 PREZENT -
## 4 10338838 M RURAL 3761107591 PREZENT -
## 5 10327360 M RURAL 3761107591 PREZENT -
## # ... with 15 more variables: `STATUS MATEMATICA` <chr>, `NOTA ROMANA` <dbl>,
## # `NOTA LIMBA MATERNA` <lgl>, `NOTA MATEMATICA` <dbl>, `CONTESTATIE
## # ROMANA` <chr>, `NOTA CONTESTATIE ROMANA` <dbl>, `CONTESTATIE LIMBA
## # MATERNA` <chr>, `NOTA CONTESTATIE LB MATERNA` <lgl>, `CONTESTATIE
## # MATEMATICA` <chr>, `NOTA CONTESTATIE MATEMATICA` <dbl>, `NOTA FINALA
## # ROMANA` <dbl>, `NOTA FINALA LB MATERNA` <lgl>, `NOTA FINALA
## # MATEMATICA` <dbl>, MEDIA <dbl>, `MEDIA V-VIII` <dbl>
The dataset contain 21 variable, but for the purpose of this study will be selected 6 variable. The next step is to rename the columns with more suggestive names. From the entire dataset will be subset the rows related to students who were absent to the National Evaluation exam, to be further analyzed.
# Select the needed columns
df2<-select(df1, 2,3,5,7,20,21)
# Rename the columns
df2<-rename(df2,Gender="SEX", Area="MEDIU", Status_ex1="STATUS ROMANA", Status_ex2="STATUS MATEMATICA", Grade_ex ="MEDIA", Grade_4y="MEDIA V-VIII")
# Filter the dataset for students who were absent to National Evaluation exam
df3<-filter(df2, is.na(Grade_ex))
summary(df2)## Gender Area Status_ex1 Status_ex2
## Length:172543 Length:172543 Length:172543 Length:172543
## Class :character Class :character Class :character Class :character
## Mode :character Mode :character Mode :character Mode :character
##
##
##
##
## Grade_ex Grade_4y
## Min. : 1.000 Min. : 5.040
## 1st Qu.: 5.100 1st Qu.: 7.800
## Median : 7.200 Median : 8.800
## Mean : 6.732 Mean : 8.599
## 3rd Qu.: 8.520 3rd Qu.: 9.520
## Max. :10.000 Max. :10.000
## NA's :11880 NA's :1
First will draw a “Violin” plot to see the distribution of grades for four years of students by gender and area.
fig1 <- df2 %>%
plot_ly(type = 'violin')
fig1 <- fig1 %>%
add_trace(x = ~Area[df2$Gender == 'F'],y = ~Grade_4y[df2$Gender == 'F'],legendgroup = 'F',scalegroup = 'F',
name = 'F', box = list(visible = T),meanline = list(visible = T),color = I("pink"))
fig1 <- fig1 %>%
add_trace(x = ~Area[df2$Gender == 'M'], y = ~Grade_4y[df2$Gender == 'M'], legendgroup = 'M', scalegroup = 'M',
name = 'M', box = list(visible = T), meanline = list(visible = T), color = I("blue"))
fig1 <- fig1 %>%
layout(xaxis = list(title = "Area"), yaxis = list(title = "Grade"), violinmode = 'group',
title = "<b>Grades for four years distribution<br><i>by students gender and area", autosize = FALSE, width = 600, height = 400)
fig1The second plot drawn is a “split Violin” that show the distribution of grades for exam of students, by gender and area.
fig2 <- df2 %>%
plot_ly(type = 'violin')
fig2 <- fig2 %>%
add_trace(x = ~Area[df2$Gender == 'F'], y = ~Grade_ex[df2$Gender == 'F'],legendgroup = 'F', scalegroup = 'F',
name = 'F', side = 'positive', box = list(visible = T), meanline = list(visible = T), color = I("green"))
fig2 <- fig2 %>%
add_trace(x = ~Area[df2$Gender == 'M'], y = ~Grade_ex[df2$Gender == 'M'], legendgroup = 'M', scalegroup = 'M',
name = 'M', side = 'negative', box = list(visible = T), meanline = list(visible = T), color = I("blue"))
fig2 <- fig2 %>%
layout(xaxis = list(title = "Area"), yaxis = list(title = "Grade"), violingap = 0, violingroupgap = 0,
violinmode = 'overlay', title = "<b>Grades for exam distribution<br><i>by students gender and area",
autosize = FALSE, width = 600, height = 400)
fig2The third plot is a histogram of exam grades distribution by students gender and area.
fig3 <- plot_ly(df2, type = "histogram", x = ~Grade_ex[df2$Gender == 'M'],color = I("blue"), name='M', legendgroup = 'M')
fig3 <- fig3 %>% add_trace(type='histogram',x=~Grade_ex[df2$Gender == 'F'],color = I("red"), name='F', legendgroup = 'F')
fig3 <- fig3 %>% layout(barmode="stack", bargap=0.2)
fig4 <- plot_ly(df2, type = "histogram", x = ~Grade_ex[df2$Area == 'URBAN'],color = I("green"), name= 'URBAN', legendgroup = 'URBAN')
fig4 <- fig4 %>% add_trace(type='histogram',x=~Grade_ex[df2$Area == 'RURAL'],color = I("purple"),name='RURAL' , legendgroup = 'RURAL')
fig4 <- fig4 %>% layout(barmode="stack", bargap=0.2)
fig_s1 <- subplot(fig3, fig4, nrows = 2)
fig_s1 <- fig_s1 %>% layout(title = "<b>Grades for exam distribution<br><i>by students gender and area",
showlegend=TRUE,showlegend2=TRUE)
fig_s1The fourth plot is a histogram of grades for four years distribution of students absent to National Evaluation exam, grouped by gender and area.
fig5 <- plot_ly(df3, type = "histogram", x = ~Grade_4y[df3$Gender == 'M'],color = I("blue"), name='M', legendgroup = 'M')
fig5 <- fig5 %>% add_trace(type='histogram',x=~Grade_4y[df3$Gender == 'F'],color = I("red"), name='F', legendgroup = 'F')
fig5 <- fig5 %>% layout(barmode="stack", bargap=0.2)
fig6 <- plot_ly(df3, type = "histogram", x = ~Grade_4y[df3$Area == 'URBAN'],color = I("green"), name= 'URBAN', legendgroup = 'URBAN')
fig6 <- fig6 %>% add_trace(type='histogram',x=~Grade_4y[df3$Area == 'RURAL'],color = I("purple"),name='RURAL' , legendgroup = 'RURAL')
fig6 <- fig6 %>% layout(barmode="stack", bargap=0.2)
fig_s2 <- subplot(fig5, fig6, nrows = 2)
fig_s2 <- fig_s2 %>% layout(title = "<b>Distribution of grades for four years<br><i>of students absent to National Evaluation exam",
showlegend=TRUE,showlegend2=TRUE)
fig_s2Analyzing the previous plots we one may observe the following:
the female students obtained higher grades for the four years, both on rural and urban area;
the same trend is observed for the grades obtained at national evaluation exam, by female students;
when we analyze the area of students provenience, we observe that grades obtained by students from Rural area are higher, on average.
most of the students who were absent to the national evaluation exam have the grades for four years in the range of 6 to 7. Another aspect that may be mentioned id that average number of students from urban area is smaller than those from rural area.