GRAPHIC ERA HILL UNIVERSITY
Haldwani Campus
ASSIGNMENT – 2
Subject: Business Analytics
Data Science Using R
Submitted By Kunal Singh Rathour
Roll No. 2497045
Programme MBA – 4th Semester
University Graphic Era Hill University, Haldwani
Session 2024 – 2026
1. Introduction to R and Data Science
R is a free, open-source programming language and environment specifically designed for statistical
computing and graphics. Developed by Ross Ihaka and Robert Gentleman at the University of
Auckland, R has grown into one of the most widely used languages in data science, academia, and
business analytics. Its strength lies in its vast ecosystem of packages — over 19,000 on CRAN —
that cover everything from machine learning and natural language processing to bioinformatics and
finance.
Data Science is an interdisciplinary field that extracts knowledge and insights from structured and
unstructured data using scientific methods, algorithms, and systems. The data science workflow
typically follows five stages: data collection, data wrangling, exploratory data analysis (EDA),
modelling, and communication of results. R provides powerful tools at every stage of this pipeline.
1.1 Why R for Business Analytics?
• Statistical depth: R was built by statisticians — it offers unmatched depth for hypothesis
testing, regression, and time-series analysis.
• Visualisation: The ggplot2 package produces publication-quality graphics with minimal code.
• Reproducibility: R Markdown integrates code, output, and narrative for fully reproducible
reports.
• Community: A large, active community ensures rapid package development and abundant
learning resources.
• Integration: R integrates with SQL, Python, Spark, Tableau, and cloud platforms seamlessly.
2. Core R Packages for Data Science
2.1 Data Manipulation – dplyr and tidyr
The tidyverse collection, spearheaded by Hadley Wickham, revolutionised R programming. The dplyr
package provides a grammar of data manipulation with verbs such as filter(), select(), mutate(),
summarise(), and arrange(). These functions allow analysts to chain operations using the pipe
operator (%>%), making code highly readable. The tidyr package handles reshaping data between
wide and long formats using pivot_longer() and pivot_wider().
2.2 Data Visualisation – ggplot2
ggplot2 implements Leland Wilkinson's Grammar of Graphics. A plot is constructed by layering
aesthetic mappings, geometric objects (points, lines, bars), statistical transformations, and coordinate
systems. This declarative approach makes it easy to produce scatter plots, histograms, box plots,
heatmaps, and faceted small multiples with a consistent syntax. Extensions such as plotly enable
interactive visualisations for web-based dashboards.
2.3 Machine Learning – caret and tidymodels
The caret package (Classification And REgression Training) provides a unified interface for over 200
ML algorithms, handling pre-processing, cross-validation, and hyperparameter tuning. The newer
tidymodels framework brings a tidy, consistent API for the entire modelling workflow — specifying
recipes, model engines, and evaluation metrics. Common algorithms available include linear
regression, random forests, support vector machines, gradient boosting (xgboost), and k-nearest
neighbours.
2.4 Text Analytics – tm and tidytext
The tm package provides infrastructure for text mining: building corpora, removing stop words,
stemming, and creating document-term matrices. The tidytext package by Julia Silge and David
Robinson extends tidy principles to text data, enabling sentiment analysis, tf-idf weighting, and topic
modelling with Latent Dirichlet Allocation (LDA) using a simple, pipe-friendly API.
3. R in the Data Science Workflow
Data Collection: R connects to databases via DBI/odbc, reads CSV/Excel/JSON files, calls
1 REST APIs using httr, and scrapes web pages using rvest.
Data Wrangling: dplyr and tidyr clean, filter, join, and reshape raw data into analysis-ready
2 formats. Missing values are handled with tidyr::drop_na() or imputation packages.
Exploratory Data Analysis: Summary statistics via skimr, correlation matrices with corrplot,
3 and rich visualisations with ggplot2 reveal patterns, outliers, and distributional properties.
Modelling: tidymodels orchestrates the full ML pipeline — splitting data, defining recipes,
4 fitting engines, cross-validating, and comparing models on held-out test sets.
Communication: R Markdown and Quarto generate dynamic HTML, PDF, and Word
5 reports. The Shiny framework builds interactive web applications powered entirely by R.
4. Conclusion
R remains one of the most powerful and versatile tools in the data scientist's toolkit. Its rich statistical
heritage, combined with modern packages like the tidyverse and tidymodels, makes it equally suited
to academic research and production business analytics. For MBA students in Business Analytics,
proficiency in R provides a significant edge — enabling rigorous analysis, compelling visualisation,
and reproducible reporting that drives data-informed decision-making across all functional areas of
management.
5. References
• Wickham, H., & Grolemund, G. (2017). R for Data Science. O'Reilly Media.
• James, G. et al. (2021). An Introduction to Statistical Learning with R. Springer.
• Silge, J., & Robinson, D. (2017). Text Mining with R: A Tidy Approach. O'Reilly.
• CRAN Task Views (2024). Machine Learning & Statistical Learning. [Link].