Module # 12 R Markdown

---
title: "Markdown Assignment for LIS4370"
author: "Issaiah Jennings"
date: "2025-04-13"
output: html_document
---

## Introduction

In this project, I worked on functions that help analyze student grade data. I used R to build functions that calculate averages, give letter grades, and filter students who are doing well. This file explains what each function does, how it works, and includes example code.

---

## Function 1: `average_grade()`

**What it does:**  
Takes a list of grades and gives back the average.

**Inputs:**  
- A vector of numbers (grades)

**Outputs:**  
- One number (the average)

**Code:**
```{r}
average_grade <- function(grades) {
  return(mean(grades, na.rm = TRUE))
}

# Example
average_grade(c(90, 85, 88))      # 87.67
average_grade(c(100, 95, NA, 85)) # 93.33

Function 2: get_letter_grade()

What it does:
Turns a number grade into a letter grade.

Inputs:

  • A number (like 87.67)

Outputs:

  • A letter (like "B")

Code:

{r}

get_letter_grade <- function(avg) { if (avg >= 90) { return("A") } else if (avg >= 80) { return("B") } else if (avg >= 70) { return("C") } else if (avg >= 60) { return("D") } else { return("F") } } # Example get_letter_grade(87.67) # "B" get_letter_grade(59) # "F"

Function 3: filter_high_performers()

What it does:
Keeps only students who scored above a certain average.

Inputs:

  • A data frame with a column called average

  • A number (threshold)

Outputs:

  • A smaller data frame with students who passed the threshold

Code:

{r}

filter_high_performers <- function(df, threshold) { return(df[df$average > threshold, ]) } # Example students <- data.frame( name = c("Alex", "Jordan", "Taylor"), average = c(92, 78, 88) ) filter_high_performers(students, 85)

R Markdown made it easy to keep my code, notes, and examples all in one place. I didn’t need to switch between files. I could just write and run everything here.

This file shows the three main functions I used for my grade analysis project. It’s clean and easy to read, and it’ll be helpful when I post it on GitHub. This was a good way to get better at coding and documenting my work.


https://github.com/Ijennin/R-Functions/blob/main/Grade_Average_Calculator.Rmd






Comments

Popular posts from this blog

Final project - create your own R Package

Module # 1 assignment(R)

Module # 4 Programming structure in R