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.
x = vector("numeric", 5) print("Numeric Type:") print(x) c = vector("complex", 5) print("Complex Type:") print(c) l = vector("logical", 5) print("Logical Type:") print(l) chr = vector("character", 5) print("Character Type:") print(chr)
Sample Output:
[1] "Numeric Type:" [1] 0 0 0 0 0 [1] "Complex Type:" [1] 0+0i 0+0i 0+0i 0+0i 0+0i [1] "Logical Type:" [1] FALSE FALSE FALSE FALSE FALSE [1] "Character Type:" [1] "" "" "" "" ""
total answers (1)
start bookmarking useful questions and collections and save it into your own study-lists, login now to start creating your own collections.
Sample Output:
need an explanation for this answer? contact us directly to get an explanation for this answer