SCMA 451- HOMEWORK 1
Introduction to R and Data Processing
This homework helps develop your knowledge on basic R commands for data processing and computing.
Submit all files you used for this assignment. You can submit a compiled Word document with
the R scripts you used.
This assignment also asks you to submit a csv file as part of the last question. Submit that file
as well.
1. Consider continuous compounding equation given below, where FV presents the future value,
PV represents the present value, with parameters r representing the interest rate and t
representing the time (years): (1.5 points)
FV= PV * er t
a. Write a generic function to calculate the FV, given all input parameters.
b. For PV =$20000 at 5% compounded continuously over 3 years what is the future value?
c. For PV =$20000 at 5% compounded continuously over 5 years what is the future value?
2. Write a script to compute following (1pt)
100
∑ 𝑖 + 3*𝑖2
𝑖=5
3. Generate 200 normal distributed values with mean 0, i.e. rnorm (200), and form a vector x
with these values. We want to replace the positive elements in x with 1 and the negative ones
with -1. (1.5)
a) Use for () loop for this operation and if-else statement to perform this operation.
b) Calculate the sum of these elements in x.
c) Rerun the random number generation 5 times and value conversion, then form a table that
displays the sum of these values in each run.
4. Use the [Link] file provided. Define a data table called “data” as a dataframe in RStudio,
then answer the following questions. (6 pts)
a) There are records which have missing values on some variables. Remove all the records
with any missing value in the data set and report how many records are removed. (1)
b) Are there outlier stores in terms of the SqFt variable? If there are, how many and
which ones?
If there are, create a table with them and display those records. (2)
Use interquartile range (IQR) to define lower whisker (lw) and upper whisker(uw)
as following:
lw=Q1-1.5*IQR and uw=Q3+1.5*IQR
c) A customer in Germany needs the square meters measured for each store. Create a
new variable called Meter2, which is defined as SqFt converted to square meters with
the following equation: 1 square foot = 0.0929 square meters
Append Meter2 to the table. (1)
d) List the stores based on the SqFt column in descending order. What are the locations
of the top 5 stores based on the SqFt. Create a table that only lists the StoreID and the
City for these records. (1)
e) Export the table from part d) to a csv file and name the file as [Link]. (1)