R Programming: Create a vector which contains 10 random integer values between -50 and +50
R Programming: Basic Exercise-4 with Solution
Write a R program to create a vector which contains 10 random integer values between -50 and +50.
Sample Solution :
R Programming Code :
v = sample(-50:50, 10, replace=TRUE)
print("Content of the vector:")
print("10 random integer values between -50 and +50:")
print(v)
Sample Output:
[1] "Content of the vector:" [1] "10 random integer values between -50 and +50:" [1] 31 -13 -21 42 49 -39 20 12 39 -2
R Programming Code Editor:
Have another way to solve this solution? Contribute your code (and comments) through Disqus.
Previous: Write a R program to create a sequence of numbers from 20 to 50 and find the mean of numbers from 20 to 60 and sum of numbers from 51 to 91.
Next: Write a R program to get the first 10 Fibonacci numbers.
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