代写PLS 021 Spring 2025 Homework 6代写数据结构语言

2025-05-12 代写PLS 021 Spring 2025 Homework 6代写数据结构语言

PLS 021 Spring 2025

Homework 6

Rstudio Part 2

Instructions

This homework is due four (4) days after your registered lab section before 11:55 pm. Please read and follow the directions.  If you have any questions, contact your TA or attend office hours.

Assignment Overview

For this assignment, you will be presented with several scenarios requiring computational solutions.  You are expected to use RStudio software to develop and run your R code to derive the necessary answers. Your submission should consist of a single R script file containing your solutions.  Ensure that you follow the submission instructions provided at the end of this homework to receive full points.

Note: The use of Artificial Intelligence tools for generating code is strictly prohibited. You are required to solve the tasks independently, following the instructions provided during class.

Task 1: Thermal profile of water in Lake Berryessa

Solar radiation heats water bodies on the Earth’s surface, though not all of the energy is absorbed by the water. Approximately 6-7% of the incoming radiation is reflected back due to the water’s albedo.  In pure water, nearly 70% of solar radiation is absorbed within the top 5 meters of the water’s depth.  The penetration depth of solar radiation can vary depending on the clarity of the water, leading to variations in water temperature with increasing depth, particularly during the summer months.  Marvin E. Jensen measured water temperature at various depths in Lake Berryessa during July 2003 and observed the same phenomenon. The resulting dataset was used to correlate ‘Depth’ and ‘Temperature’ using a simple sigmoidal curve fit. The equation is:

Your task is to help visualize the temperature of water at different depths of the water based on the instructions provided below.

1.  Create a variable named Depths that contains values ranging from 5 to 25 incre- menting by a value of 5.  (1 pt.)

2.  Use for-loop to iterate among the different depth values in Depths  and calculate Temperature for each values of Depths using the equation provided above and print them. Store the printed values in a single variable called WaterTemp.(2 pt.)

3.  Create a scatter plot with  WaterTemp in y axis and Depths in x axis.  (1 pt.)

Task 2: Identifying odd and even digits in your Stu- dent ID

For this task, you will identify the odd and even digits in your Student ID. Note that “0” should be considered an even number. Follow the instructions provided below:

1.  Create a variable MyID by concatenating the numerical digits from your Student ID. Make sure to use your actual SIS Student ID. Hint:  if your student ID is 919198498, you will need to concatenate 9, 1, 9, 1, 9, 8, 4, 9, and 8.  (1 pt.)

2. Use a for-loop  to  iterate through the digits in  MyID.  For each iteration,  print whether the numerical digit is odd or even.  (2 pt.)

Share your R code along with the results, and include an explanation of how you personalized  the  input  values  by  adding  comments.    Ensure  that  your  code  is  well- documented, with comments that clarify your choice of input values and explain each step of your solution.

Task 3: Calculating investment pay-back period

You recently decided to help your family install solar panels on the roof of your home. The total cost of the solar panels was $X  (replace X with a value you choose).  Each year, your family saves $Y on electricity bills because of the solar panels (replace Y with a value you choose).

Write an R program using a ‘while’ loop to calculate how many years it will take for your family to recover the entire initial investment through the annual savings based on the instructions provided below-

1. The value for X (total cost) and Y (annual savings) depends on your birth month and day.

X = 10, 000 + (month × 1000)

Y = 500 + (day × 10)

For example: If your birthday is April 15th, you might choose X = 10, 000 + (4 × 1000) and Y = 500+(15 × 10).  If your birthday is December 3rd, you might choose X = 12, 000 + (12 × 1000) and Y = 600 + (3 × 20).

2. Write the full equation that you have used to calculate the value of X and Y in you Rscript.  Make sure to adjust your values for X and Y so they reflect a realistic scenario. Put your actual birthday (month and day number) that you have used to calculate value of X and Y as comment.  (1 pt.)

3. Implement the solution using a ‘while’ loop to determine the number of years re- quired to recover the initial investment. (2 pt.)

Share your R code along with the results, and include an explanation of how you personalized  the  input  values  by  adding  comments.    Ensure  that  your  code  is  well- documented, with comments that clarify your choice of input values and explain each step of your solution.

Instructions for Submitting Coding Tasks

1.  Complete all three coding tasks using the desktop version of RStduio software.

2.  Ensure that each task is clearly separated within the same R script file.  You can do this by adding comments to label each task. Use the format below:

# Task 1:

# (Your code for Task 1 here)

# Task 2:

# (Your code for Task 2 here)

# Task 3:

# (Your code for Task 3 here)

3.  Save all tasks in a single R script file named Section LastName FirstName HW6 . R (e.g., A01 Bailey Brian HW6. R).

4.  Upload your R script file to Canvas, which should include the necessary code for all the above-mentioned tasks.

5. Important:  Do not upload any other type of file except for an R script file with the  . R extension.  Failure to follow this instruction will result in 0 points for this homework.

Note: Ensure that the code is properly formatted and commented so that each task is easy to identify and review.