Homework 02 – Program Control & Data Manipulation

Description

I will attach the instructions below and the rmd with the cvs file is in the link below. Thank you for helping me.The link to rmd file: https://drive.google.com/drive/folders/1A5-7HJgp0u…

Don't use plagiarized sources. Get Your Custom Assignment on
Homework 02 – Program Control & Data Manipulation
From as Little as $13/Page

Unformatted Attachment Preview

ITEC-300 Homework 02 – Program Control & Data
Manipulation
Angela Virtu
1/26/2024
Table of Contents
General Instructions………………………………………………………………………………………………………………………. 1
Knitting…………………………………………………………………………………………………………………………………………….. 1
Q1. Functions & Program Control (20 points) ………………………………………………………………………….. 2
Q2. External Data (15 points) ………………………………………………………………………………………………………. 2
Q3. Group Manipulation – apply() family of functions (35 points) ……………………………………….. 3
Q4. Group Manipulation – aggregate() (25 points) ………………………………………………………………….. 4
Q0: Homework Retrospective (5 points) …………………………………………………………………………………… 5
General Instructions
1.
Download the R Markdown template for this homework
itec_300_hw_02_YourLastName.Rmd and save it to your class project folder.
Rename the file to replace YourLastName with your own last name.
2.
Open the file in RStudio and complete the coding exercises and answer the
interpretation questions. Run the code to ensure everything is working fine.
3.
I will always display the homework code output in the instructions on Canvas, so
that you can compare your results against the solution. Technical Note: Your
quantitative and visual outputs should look identical to the outputs shown in the
homework. Now is a good time to compare your results, and ask me with questions
if they differ.
4.
When done, knit your R Markdown file into a Word document. On Canvas please
submit both the knitted word document AND the .rmd file. If you have troubles
knitting a word file, you can knit to a PDF file, or to an HTML file and then save it as
a PDF.
Knitting
Preparing analytic reports using the {knitr} package is an important learning objective of
this course. Your R Markdown file MUST have the attribute echo=T in the {r global options}
so that we can see and grade your R code. You are required to knit your homework R
Markdown files to a Word (preferred) or PDF file. The knitted document should adhere to
proper business-like formatting and appearance.
As such, inadequate or no knitting will carry point deductions up to 10 points max.
Q1. Functions & Program Control (20 points)
1.1 (7 points): We want to calculate the area of many shapes. Write a function named
area() that takes 3 values as parameters (base, height, and sides). The function should
contain an if/else statement that contains the following program control logic:

if sides equals 3 then return() the area of a triangle. The formula to calculate the
area of a triangle is 1/2 * base * height

if sides equals 4 then return() the area of a rectangle. The formula to calculate the
area of a rectangle is base * height

otherwise, return() the string Not Applicable
Then use the area() function to return the area of a 4-sided shape with a base of 2 and a
height of 13.
## [1] 26
1.2 (6 points): Which core principle of R (reproducibility, computational speed,
presentation) do functions() embody? Why?
1.3 (7 points): Write a simple while loop that iterates while i
Purchase answer to see full
attachment