mean ca be calculated by adding the elements and dividing that sum with the count of elements.
For creating an R program to find the 'sequence', 'sum', and 'mean' of the given numbers, we are using built-in functions seq(), mean(), and sum(). The user input is passed to these functions from the main program.
seq(from, to)
sum(…, na.rm = FALSE)
mean(x)
In this R program, we directly give the values to built-in functions that are 'seq()', 'mean()', and 'sum()'. These are the built-in functions in R that can do the processing and return the result to the main program. Finally, we print the return values as results.
STEP 1: Use the R functions and pass the values into it
STEP 2: call seq()
with the lower and upper limit as the arguments
STEP 3: call mean()
mentioning the limit of numbers
STEP 4: call sum()
with two values which are the upper and lower limits.
STEP 5: print the return value from each function
print("Sequence of numbers from 20 to 40:")
print(seq(20,40))
print("Mean of numbers from 20 to 60:")
print(mean(20:60))
print("Sum of numbers from 51 to 91:")
print(sum(51:91))
[1] "Sequence of numbers from 20 to 40:" [1] 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 [1] "Mean of numbers from 20 to 60:" [1] 40 [1] "Sum of numbers from 51 to 91:" [1] 2911