please help me writing R script for these two task.. help me with the code... i will insert csv file myself
- (3 marks) Read the "assignment1.csv" file and Save it as a dataframe named "CerealsDF" Display the structure of "CerealsDF" using str() function and examine the variables and their classes Display the first ten rows of "CerealsDF" - (3 marks) The second line in "CerealsDF" represents the data type of each column. Delete this line from the dataframe Print the number of rows and columns in the data frame Add a new column named "totalcarbo" that shows the total of both carbo and sugars columns - S 3 marks) The "type" column shows the type, i.e., hot or cold, of the cereal and "mfs" column shows the manufacturer of the cereal. Find how many cereals are hot. Use subset() function Find how many unique manufacturers are mentioned in the dataframe. Use unique() function Extract all cereals that are manufactured by Kellogg's ("K"). Call this dataframe as "cereals_ K " and print it - (3 marks) To examine the total value of each type, we.need to look at the values of two or more columns. - Extract all cereals that have less than or equalig0, calories AND have more than 2 units of fat Save this subset as a CSV file on your desk. Use wirte.csv() function Task II: Vectors, Functions, Series ( 12 marks) You are given the following discrete data that represent the following function: f(x)=cos0.5xe0.1x - Write an R function that implement the Interpolation formula shown in the class. Call this function MyIntCal(). - What is degree of the interpolating function? - You should have seven Lagrange polynomials, L1, L2, ... L7. Create a 42 figure and plot each of these polynomials in one subfigure. Add the final interpolating function in the last subfigure. Save this figure as MyIntFig.pdf - Use the built in function poly.calc() to find the interpolating function and call it pf_x. - Find the value of f(15) using MyintCal() and pf_x. - Find the value of f(24) using MyintCal() and pfx