R Programming: Create a vector and find the length and the dimension of the vector
R Programming: Vector Exercise-24 with Solution
Write a R program to create a vector and find the length and the dimension of the vector.
Sample Solution :
R Programming Code :
v = c(1,3,5,7,9)
print("Original vectors:")
print(v)
print("Dimension of the vector:")
print(dim(v))
print("length of the vector:")
print(length(v))
Sample Output:
[1] "Original vectors:" [1] 1 3 5 7 9 [1] "Dimension of the vector:" NULL [1] "length of the vector:" [1] 5
R Programming Code Editor:
Have another way to solve this solution? Contribute your code (and comments) through Disqus.
Previous: Write a R program to convert two columns of a data frame to a named vector.
Next: Write a R program to combines two given vectors by columns, rows.
Test your Programming skills with w3resource's quiz.
What is the difficulty level of this exercise?
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics