Create only one script file for this assignment. To be able to test the code, I should be able to execute the "bestFitFu
Posted: Tue Jul 12, 2022 8:17 am
o the maximum of all columns. except the first two. Those are to be ignored. Find the best-fit function of the total vaccinations administered on a daily basis. The function has the form TV = a xebt Where TV is the total vaccinations, a and b are constants, and t is the day. • Write R code to calculate the value of these two constants using non-linear regression. Hint: Refer to the example given in the lecture, and follow the steps to transform the data to linear regression. • Your code must present two menus to the user. The first should look like this: MENU 1. Exponential Fit 2. Quit If the user selects 1, they should see this Please enter the name of the file to open: The user will enter "assignment2.xslx", at which point your code will load the script. Use the file name provided by the user. Once loaded, prompt the user for some start and end dates: Please enter the start date (dd/mm/yyyy): Please enter the end date (dd/mm/yyyy) : These start and end dates must fall between 01/02/2021 and 01/05/2021. The end date must be at least 60 days greater than the start date. • The code will find the best fit using the exponential function and then print the function to the user. Then, the user will be prompted with the second menu: MENU 1. Extrapolation 2. Main Menu If the user selects 2, go back one menu. If the user selects 1, the code will ask the user what date they would like to extrapolate to:
4 of 4 MENU 1. Extrapolation 2. Main Menu • If the user selects 2, go back one menu. If the user selects 1, the code will ask the user what date they would like to extrapolate to: Please enter the date to extrapolate to (dd/mm/yyyy) : • Calculate the estimated total vaccinations on that date and print the result. Plot the total vaccinations during the entered range, and plot the best-fit function on the same graph. You must use the right titles for the graph, x-axis and y-axis. . Finally, save the plot as total_vacc.pdf.