Programs to try using vectors - Assignment 5
Program List
1.Find the largest and second largest element in a vector.
2.Read n numbers and find sum, mean, min, max,median,variance ,standard deviation(use built in fn)
3.Reverse a vector (using rev() and without using rev()
)4.Find the frequency of each element in a vector.( use table() , without using table -use unique())5.Remove duplicate elements(unique and without using unique use %in%)
6.Find the common elements between two vectors.(use intersect() and without using intersect)
7.Read two vectors and find the dot product. ( use sum() and a user defined function)
8.Replace all negative elemnts with 0 ( use ifelse, use loop)
9.Generate n fibonaci numbers and store in a vector
10.Print the cumulative sum and also print the intermediate sum (use cumsum() and without using cumsum)
Vector: 10 20 30 40 50
Cumulative Sum: 10 30 60 100 150
11.Find mode ( the most frequent item)
12.Find variance and standard deviation ( use var() and sd() and without using bult-in functions)
13.Seperate even and odd numbers from a vector into new vectors.
14.Write an R program to read a vector and use a user-defined function to count the number of even and odd elements.
15.Write an R program to read a vector and use a user-defined function to find and return a named vector containg sum, mean, min and max.
Note:
Students should develop algorithms and implement the programs without relying on built-in functions. Built-in functions may be used only to verify the correctness of the obtained results. These programming assignments are intended to strengthen problem-solving abilities and enhance programming skills in R.
Comments
Post a Comment