

Step 4: Create a new categorical variable dividing the month with three level: begin, middle and end. They are resistant to outliers (anything which affects the midpoint of the upper half or lower half of the distribution isn’t an outlier). Before you start to create your first boxplot () in R, you need to manipulate the data as follow: Step 1: Import the data. The formula is easy to implement as a method ( rank values, count quarter intervals, measure the difference).

Yet, another reason R is such an excellent data science tool.Īs a starting point for descriptive statistics, finding the median (middle number) and interquartile range has the advantage of being being simple to calculate and easy to explain.
#Summary r studio code
Using IQR in R and the summary() function reduces what would otherwise take over a dozen lines of code down to just two. Also, notice how the quartiles have shifted due to this change.įinding the interquartile range in R is helpful for knowing the spread of a data set. See how the median of 20 is the average of 18 and 22. Here is an example of a data set with an even number of data points. # interquartile range in R summary() procedure It shows the same median, quartiles and interquartile range as we manually calculated. Here is the data set of our earlier example having been put through both the summary and IQR functions. Its companion summary function has the format of summary(data set) and returns the minimum value, maximum value, median, mean, the first quartile and the third quartile. It has the format of IQR(data set) and returns the interquartile range for that data set. You can also get the median and the first and second quartiles with the summary() function.įinding the interquartile range in R is a simple matter of applying the IQR function to the data set, you are using. Finding the IQR in R is a simple matter of using the IQR function to do all this work for you.
