w3resource

R Programming Vector: Exercises, Practice, Solution

R Programming Vector [28 exercises with solution]

[An editor is available at the bottom of the page to write and execute the scripts. Go to the editor]

1. Write a R program to create a vector of a specified type and length. Create vector of numeric, complex, logical and  character types of length 6.
Click me to see the sample solution

2. Write a R program to add two vectors of integers type and length 3.
Click me to see the sample solution

3. Write a R program to append value to a given empty vector.
Click me to see the sample solution

4. Write a R program to multiply two vectors of integers type and length 3.
Click me to see the sample solution

5. Write a R program to divide two vectors of integers type and length 3.
Click me to see the sample solution

6. Write a R program to find Sum, Mean and Product of a Vector.
Click me to see the sample solution

7. Write a R program to find Sum, Mean and Product of a Vector, ignore element like NA or NaN.
Click me to see the sample solution

8. Write a R program to find the minimum and the maximum of a Vector.
Click me to see the sample solution

9. Write a R program to sort a Vector in ascending and descending order.
Click me to see the sample solution

10. Write a R program to test whether a given vector contains a specified element.
Click me to see the sample solution

11. Write a R program to count the specific value in a given vector.
Click me to see the sample solution

12. Write a R program to access the last value in a given vector.
Click me to see the sample solution

13. Write a R program to find second highest value in a given vector.
Click me to see the sample solution

14. Write a R program to find nth highest value in a given vector.
Click me to see the sample solution

15. Write a R program to find common elements from multiple vectors.
Click me to see the sample solution

16. Write a R program to convert given dataframe column(s) to a vector.
Click me to see the sample solution

17. Write a R program to extract every nth element of a given vector.
Click me to see the sample solution

18. Write a R program to list the distinct values in a vector from a given vector.
Click me to see the sample solution

19. Write a R program to find the elements of  a given vector that are not in another given vector.
Click me to see the sample solution

20. Write a R program to reverse the order of given vector.
Click me to see the sample solution

21. Write a R program to concatenate a vector.
Click me to see the sample solution

22. Write a R program to count number of  values in a range in a given vector.
Click me to see the sample solution

23. Write a R program to convert two columns of a data frame to a named vector.
Click me to see the sample solution

24. Write a R program to create a vector and find the length and the dimension of the vector.
Click me to see the sample solution

25. Write a R program to combines two given vectors by columns, rows.
Click me to see the sample solution

26. Write a R program to test whether the value of the element of a given vector greater than 10 or not. Return TRUE or FALSE.
Click me to see the sample solution

27. Write a R program to add 3 to each element in a given vector. Print the original and new vector.
Click me to see the sample solution

28. Write a R program to create a vector using : operator and seq() function.
Click me to see the sample solution

R Programming Code Editor:


More to Come !

Do not submit any solution of the above exercises at here, if you want to contribute go to the appropriate exercise page.



Become a Patron!

Follow us on Facebook and Twitter for latest update.

It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.

https://w3resource.com/r-programming-exercises/vector/index.php