Description
Assignment 7
1. Create a data matrix named MARKS having marks of three subjects SUB1, SUB2 and SUB3 for 20 students. Use apply function
a. To find total marks of each students.
b. Append the total to the given MARKS dataset.
c. To create a function called st.err()=sd(x)/sqrt(length(x)) to find the standard error in SUB1, SUB2, and SUB3.
d. Add 0.25 bonus marks to each mark in SUB1, SUB2 and SUB3.
2. Create three vectors V1, V2, and V3 from the SUB1, SUB2, and SUB3 above respectively. Use lapply() function to find the sum of all the marks in V1, V2, and V3.
3. Create a vector TOTAL_SUM that hold the value of V1, V2, and V3 using sapply().
4. Compute the square of each value of marks in V1, V2, and V3 using sapply().
5. Add an index field I =(1,1,1,1,1,2,2,2,2,2,3,3,3,3,3,4,4,4,4,4) to matrix MARKS. Use tapply() function to compute mean() and sd() of SUB1 based on index I.
6. Create a function f(x,y)=x/y where x is V1 and y is V2. Use mapply() to compute this function.
7. Practice all apply functions on “Seatbelts” data set given in R.
Reviews
There are no reviews yet.