To write an R program for creating a vector and calculate its length and its dimension, we are using the built-in functions dim(), and length().
The syntax of these are
In this R program, we directly give the values to built-in functions, before that we are displaying the vector values. Then, we consider the variable A in which vector value is assigned. Call the functions dim() for finding dimension and length() for finding the length of the vector. Finally, print the result.
STEP 1: Assign variable A with vector values
STEP 2: Display the real vector values
STEP 3: Call the function dim() as dim(A)
STEP 4: print the result of the function
STEP 5: Call the function length() as length(A)
STEP 6: print the result of the function
A = c(1,3,5,7,9,6) print("Original vectors is:") print(A) print("Dimension of the vector is:") print(dim(A)) print("length of the vector is:") print(length(A))
 "Original vectors is:"  1 3 5 7 9 6  "Dimension of the vector is:" NULL  "length of the vector is:"  6