Q:

Write a R program to create a vector using : operator and seq() function

0

Write a R program to create a vector using : operator and seq() function.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

x = 1:15
print("New vector using : operator-")
print(x)
print("New vector using seq() function-")
print("Specify step size:")
y = seq(1, 3, by=0.3)  
print(y)
print("Specify length of the vector:")
z = seq(1, 5, length.out = 6)
print(z)

Sample Output:

[1] "New vector using : operator-"
 [1]  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15
[1] "New vector using seq() function-"
[1] "Specify step size:"
[1] 1.0 1.3 1.6 1.9 2.2 2.5 2.8
[1] "Specify length of the vector:"
[1] 1.0 1.8 2.6 3.4 4.2 5.0

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now