First -R- Package
Purpose and Scope
https://github.com/shanzay28/Friedman/tree/master
The Friedman package was developed for my LIS4370 R Programming course to explore how R packages are structured, documented, and shared. It is designed for students, data analysts, and beginners in R who want to understand how functions, metadata, and documentation fit together in a reusable library. This package provides simple utility functions that demonstrate clean coding, proper documentation, and reproducibility practices. Users can install it directly from GitHub and test small, practical functions for everyday data analysis tasks.
Key Functions
The current version (0.0.0.9000) includes four basic but well-documented functions:
• hello() – Prints a friendly “Hello, world!” message confirming that the package loads correctly.
• add_numbers(x, y) – Adds two numeric values and returns their sum with input validation.
• calculate_mean(x, na.rm = TRUE) – Computes the mean of a numeric vector, safely handling missing values.
• fahrenheit_to_kelvin(temp_F) – Converts temperature from Fahrenheit to Kelvin using the standard formula.
Future versions may include additional converters, simple descriptive statistics, or visual summaries to expand its educational value.
DESCRIPTION
File Decisions
Each field in the DESCRIPTION file was intentionally chosen to meet best practices for R package development.
• Package & Title: “Friedman” with the title “Example Package for LIS4370,” reflecting its academic purpose.
• Version: 0.0.0.9000 — a development version format used during early stages.
• Authors@R: Identifies me as the sole author and maintainer: person("Shanzay", "Khan", email = "shanzay282@gmail.com", role = c("aut","cre")).
• Description: Explains that this is a demo package containing simple functions for arithmetic and data exploration.
• License: I chose MIT + file LICENSE for openness and flexibility with attribution.
• Depends: R (>= 4.2.0) ensures compatibility with modern R environments.
• Encoding: UTF-8 for consistent text encoding.
• URLs: Added links to my GitHub repository and issue tracker for transparency.
• Roxygen: Set to list(markdown = TRUE) so documentation is generated automatically using roxygen2.
Building Friedman taught me how to make, test, and distribute R packages. I learnt how to describe functions, handle dependencies, and verify the package using devtools::check() using usethis, devtools, and roxygen2. After resolving all warnings and notes, I successfully published the package to GitHub, completing the full workflow from creation to distribution.
This experience helped me appreciate how professional developers organize, test, and maintain reproducible R tools.While developing Friedman, I followed the tutorial video shared in class, which explained step-by-step how to create an R package using usethis and devtools. The video greatly helped me grasp how the DESCRIPTION file, NAMESPACE, and roxygen2 documentation process function in a package.It made the whole process much easier and gave me the confidence to troubleshoot errors on my own.
Comments
Post a Comment