{r setup} library(reticulate) library(ggplot2) library(dplyr)

1. Import Data dengan Python

{python} import pandas as pd

df = pd.read_csv(“StudentPerformanceFactors.csv”) df.head()

2. Kirim Data ke R

{r} df <- py$df head(df)

3. Histogram Nilai Ujian

{r} ggplot(df, aes(x = Exam_Score)) + geom_histogram(bins = 20, fill = “steelblue”) + theme_minimal() + labs(title = “Distribusi Nilai Ujian”)

4. Scatter Plot Jam Belajar vs Nilai

{r} ggplot(df, aes(x = Hours_Studied, y = Exam_Score)) + geom_point() + geom_smooth(method = “lm”, se = FALSE) + theme_minimal() + labs(title = “Korelasi Jam Belajar vs Nilai Ujian”)

5. Barplot Rata-rata Nilai per Motivation Level

{r} df %>% group_by(Motivation_Level) %>% summarise(MeanScore = mean(Exam_Score)) %>% ggplot(aes(x = Motivation_Level, y = MeanScore, fill = Motivation_Level)) + geom_col() + theme_minimal() + labs(title = “Rata-rata Nilai Berdasarkan Motivation Level”)