Description Usage Arguments Value Note See Also Examples
View source: R/sims-teaching.R
Shows the steps in the manual calculation of the median and IQR.
1 2 3 4 |
x |
A numeric vector |
mdnInBoth |
A logical that indicates whether the median should be placed into both halves or not (DEFAULT) when computing the IQR with odd n. |
... |
Other arguments to the generic |
A list containing the sample size (n
); the sample Q1, median, and Q3 in the name vector vals
; the positions of the sample Q1, median, and Q3 in the named vector pos
; the ordered data (x
); and the ordered lower- (lwr
) and upper-halves (upr
) of the data.
This function shows the ordered data with the median shown and the ordered lower- and upper-halves of data with the Q1 and Q3 values shown. This function puts the median into both halves of the data to compute Q1 and Q3.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | ## Simple examples
iqrCalc(1:7)
iqrCalc(1:7,mdnInBoth=TRUE)
iqrCalc(1:8)
iqrCalc(1:8,mdnInBoth=TRUE)
iqrCalc(1:9)
iqrCalc(1:9,mdnInBoth=TRUE)
iqrCalc(1:10)
iqrCalc(1:10,mdnInBoth=TRUE)
## Somewhat more realistic
iqrCalc(sample.int(99,11,replace=TRUE))
iqrCalc(sample.int(99,12,replace=TRUE))
iqrCalc(sample.int(99,13,replace=TRUE))
iqrCalc(sample.int(99,14,replace=TRUE))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.