Applied Statistics Lab: Lab 01 – Data with R and
RStudio
Group number: 1
Student Name/ ID:
- Dương Nữ Yến Phương - BTBCIU25004
- Phạm Ngọc Diễm Quỳnh - BTFTIU25023
- Lê Khánh Ngọc - BTFTIU25025
Instructor: Dr. Ngo Thi Thuan
Date: 27/2.2026
1. Abstract
1.1 Purpose of the lab
The primary goal of this lab is to introduce students to the foundational tools for statistical
computing and reproducible research. It aims to help students:
- Install the necessary software environment on their operating system.
- Understand the RStudio interface and its core functions.
- Gain proficiency in running basic R commands.
- Learn how to generate professional, reproducible reports using R Markdown.
1.2 Software used (R, RStudio, R Markdown)
- R: A free, open-source programming language designed for statistical computing,
data analysis, and visualization.
- RStudio: An Integrated Development Environment (IDE) that provides a user-
friendly interface for writing code, viewing results, and managing data objects in
memory.
- R Markdown: A file format used to combine narrative text, executable R code, and
output (such as tables and figures) into a single, cohesive document.
1.3 Main tasks performed
The lab involves several technical and practical exercises:
- Setup: Downloading and installing R and RStudio.
- Coding Basics: Executing arithmetic operations, creating objects (variables), and
working with data structures like vectors, characters, and matrices.
- Data Management: Importing data from external Excel (CSV) files into RStudio for
analysis.
- Reporting: Creating an R Markdown file, inserting code chunks, and "knitting" the
document to generate a report in Word, PDF, or HTML format.
- Publishing: Publishing the final report to RPubs and sharing the link.
1.4 Overall outcome
By the end of the lab, students are expected to be able to navigate the RStudio environment—
including the Script Editor, Console, and Environment panes—independently. The final
deliverable is a knitted R Markdown report that demonstrates their ability to execute R code
and present findings in a reproducible and organized manner.
2. Introduction
2.1 Why R is important in science
R is a free, open-source programming language. It is highly significant in the
scientific community because it is widely used for:
- Statistical computing.
- Data analysis.
- Visualization.
2.2 Importance of reproducible analysis
Modern scientific research mandates reproducible data analysis to ensure scientific
integrity. The importance lies in the following:
- Consistency: It ensures that the same code and data always produce the
exact same results.
- Error Reduction: Traditional "copy-paste" workflows can introduce human
errors.
- Transparency: Reproducible workflows increase transparency by clearly
showing the path from raw data to final results.
- Automation: Using tools like R Markdown allows for automatic execution of
code where results are inserted directly into the report when "knitted".
2.3 Objectives of Lab 01
The learning outcomes (LO) and objectives for this laboratory session are for students to be
able to:
- LO1: Install R and RStudio on their computer's operating system.
- LO2: Describe and understand the RStudio interface and its various functions.
- LO3: Run basic R commands.
- LO4: Create and export a comprehensive lab report using R Markdown.
3. Materials and Methods
3.1 Software
- R version : 4.5.2
- RStudio version : 2026.01.0+392
3.2 Workflow
Installation:
- Firstly, R was downloaded and installed from the official website
([Link]
- After installing R, RStudio was then downloaded and installed from its official
website ([Link]
Creating R script
- An R Script was created in RStudio to store and execute the statistical
analysis commands.
Creating R Markdown
- An R Markdown file was prepared to combine code, output, and explanations.
Running code
- The code was executed to perform statistical analysis
Knitting report
- Finally, the report was generated by knitting the R Markdown file into PDF/HTML
format.
4. Results and discussions
(output only) (# echo=FALSE hides code in the main report (Sections 1–6) but still
runs it)
4.1 Basic Calculations
4.2 Variables and Vectors
4.3 Data Frame Creation
• Printed table
5. Discussion
Through this lab, we learned how to use basic R commands and understand fundamental
programming concepts such as basic calculations, variables, vectors and data frame creation.
We also learned how to organize analysis using R Markdown.
In addition, some common errors we encountered during the lab included missing
parentheses, typing mistakes, and confusion between numeric and character data types.
R helps scientific analysis by allowing fast calculations and documenting the entire analysis.
This makes it easy to share, reproduce, and rerun the analysis when needed.
6. Conclusion
In conclusion, this lab provided essential skills in R programming, including basic
calculations, variables, vectors, and data frame creation. It also introduced the use of R
Markdown for reproducible reporting.
The knowledge gained from this lab forms a strong foundation for future courses involving
statistics and data analysis.
7. Appendix (Mandatory)
7.2. R Markdown Code:
To show code and its corresponded output in the Appendix, use a chunk with
echo=TRUE:
you may paste them as plain text here or re-run chunks with echo=TRUE.
RPubs Web