2) Establish Range in R.

This Blog entry is from the Summary Statistics and Basic Plots section in Learn R.

To establish the range of the Interim_Close in the AAPL data frame use the min() function typing:

min(AAPL$Interim_Close)
1.png

Run the line of script to console:

2.png

It can be seen that the smallest value in the Interim_Close vector of the AAPL data frame is 50.67, to retrieve the largest value use the max() function by typing:

3.png

Run the line of script to console:

4.png

It can be observed from the console that the largest price is 702.1.  The range can be calculated by subtracting the maximum value from the minimum value.  The values can be presented more succinctly using the range() function and typing:

range(AAPL$Interim_Close)
5.png

Run the line of script to console:

6.png

To establish the range value subtract the largest value from the smallest value which can be archived by using the diff() function on the vector returned from the range() function as:

diff(range(AAPL$Interval_Close))
7.png

Run the line of script to console:

8.png

It can be seen that the range has been returned as being 651.43.