0% found this document useful (0 votes)
34 views1 page

Practice On Vector, Matrix

The document discusses R programs for performing operations on vectors and matrices including adding vectors, finding sums and means, sorting, extracting elements, and converting between vector and matrix forms.

Uploaded by

Prabhat Singh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
34 views1 page

Practice On Vector, Matrix

The document discusses R programs for performing operations on vectors and matrices including adding vectors, finding sums and means, sorting, extracting elements, and converting between vector and matrix forms.

Uploaded by

Prabhat Singh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

1. Write an R program to add two vectors of integer type and length 5.

2. Write a program to find sum, mean of a vector of length 5r.


3. Write a program to sort a Vector in ascending and descending order.
4. Write a program to print even numbers in your vector.
5. Print the highest element of your vector. n=1 print(sort(v,decreasing = TRUE)[n])
6. Print common elements of 3 vectors. result = intersect(intersect(x,y),z)
7. Create a vector of 1 to 50 numbers. Print every 5 th element. result = v[seq(1, length(v), 5)]
8. Print all distinct elements of a vector. print(unique(v)), reverse order – rev(v)
9. Create a matrix of 1 to 16 numbers (4x4)
10. From the above matrix access the elements at 3 rd column and 2nd row, only the 3rd row and
only the 4th column of a given matrix. (write 3 separate commands)
11. From the matrix of 16 numbers, extract numbers above 7. (Note that the result would be a
vector of 9 numbers). From this result create a 3x3 matrix.
12. Convert a matrix into 1-D array (vector) with as.vector(matrix_name)

You might also like