This function calculates the statistical measures needed to visualize the boxplot of a numeric vector.

ds.box(x, c=1.5, c.width = 0.15 , out = TRUE, tojson=FALSE)

Arguments

x

The input numeric vector

c

Determines the length of the "whiskers" plot. If it is equal to zero or out=F, no outliers will be returned.

c.width

The width level is determined 0.15 times the square root of the size of the input vector

out

If TRUE the outliers will be computed at the selected "c" level (default is 1.5 times the Interquartile Range).

tojson

If TRUE the results are returned in json format

Value

Returns a list or a json file with the following components:

  • lo.whisker The extreme of the lower whisker

  • lo.hinge The lower "hinge"

  • median The median

  • up.hinge The upper "hinge"

  • up.whisker The extreme of the upper whisker

  • box.width The width of the box (default is 0.15 times the square root of the size of the vector)

  • lo.out The values of any data points which lie below the extreme of the lower whisker

  • up.out The values of any data points which lie above the extreme of the upper whisker

  • n The non-NA observations of the vector

Details

This function returns a list with the parameters needed to visualize a boxplot.

See also

ds.analysis, open_spending.ds

Examples

# with vector as an input and the default parameters vec <- as.vector(iris$Sepal.Width) ds.box(vec)
#> $lo.whisker #> [1] 2.2 #> #> $lo.hinge #> [1] 2.8 #> #> $median #> [1] 3 #> #> $up.hinge #> [1] 3.3 #> #> $up.whisker #> [1] 4 #> #> $box.width #> [1] 1.84 #> #> $lo.out #> [1] 2 #> #> $up.out #> [1] 4.4 4.1 4.2 #> #> $n #> [1] 150 #>
# with vector as an input and the different parameters vec <- as.vector(iris$Sepal.Width) ds.box(vec, c = 3, c.width = 0.20 , out = FALSE, tojson = FALSE)
#> $lo.whisker #> [1] 2 #> #> $lo.hinge #> [1] 2.8 #> #> $median #> [1] 3 #> #> $up.hinge #> [1] 3.3 #> #> $up.whisker #> [1] 4.4 #> #> $box.width #> [1] 2.45 #> #> $lo.out #> NULL #> #> $up.out #> NULL #> #> $n #> [1] 150 #>
# OpenBudgets.eu Dataset Example: amounts <- as.vector(Wuppertal_df$Amount) ds.box(amounts, c = 1.5, c.width = 0.20, out = TRUE)
#> $lo.whisker #> [1] -2040681 #> #> $lo.hinge #> [1] 243696.1 #> #> $median #> [1] 736038.1 #> #> $up.hinge #> [1] 2653000 #> #> $up.whisker #> [1] 6243114 #> #> $box.width #> [1] 15.78 #> #> $lo.out #> numeric(0) #> #> $up.out #> [1] 11433219 6698355 12588303 13908794 13434983 13367695 6273959 #> [8] 20363834 7459153 18596765 7482458 38919541 12087507 52347353 #> [15] 33998451 123000513 21222047 6678582 10725693 7762162 6925184 #> [22] 35751463 10341147 7408926 15254723 35090973 27082754 27146703 #> [29] 13157264 13167243 37880258 8243835 8419427 7561194 6518003 #> [36] 9341974 9609349 19359142 33220817 109882054 98946317 7896179 #> [43] 8567428 57662324 7021751 14111218 69430567 71373909 19809289 #> [50] 8277711 28196859 13125331 16108616 12545655 13490920 6634403 #> [57] 20484759 9902481 14960053 7721153 14120206 14235182 11618489 #> [64] 53727427 32266240 126131502 21566311 6578563 7860372 8671186 #> [71] 9812885 8225251 8380744 9960402 28090219 28166391 18827216 #> [78] 11507974 6644276 14359599 38461868 8032943 9396412 20507284 #> [85] 32293810 118183158 107031348 9335567 8207342 62452663 8096431 #> [92] 48053894 69163751 11871817 16994157 16861927 7922346 6828339 #> [99] 40211120 9785389 23363671 23703989 8957646 16774036 38397389 #> [106] 6441219 110490838 98463131 68664650 9167526 27520836 9129925 #> [113] 12303206 12299368 6539209 8811953 18710699 23690190 37382608 #> [120] 7737027 8674230 12083178 18657799 9134164 46721277 125413158 #> [127] 11413752 50736849 313792985 87079489 6549653 377304133 45220103 #> [134] 14698820 56394866 9779963 8935805 8095440 37885319 27807840 #> [141] 27344379 25199092 13654755 40005202 68664650 54068636 63789829 #> [148] 8406014 6552749 11444153 14893324 7555817 9520040 7746267 #> [155] 8936067 27766643 14219627 14270231 14559481 20169875 6355789 #> [162] 6385814 19465000 9298807 11528091 17153831 7495974 11624622 #> [169] 55127807 65966865 148072678 33398527 8214232 8058520 7679178 #> [176] 7700732 9509631 28758152 28678071 16852268 12834422 6434959 #> [183] 14851502 42919047 8033499 9362517 19954589 35681724 107325831 #> [190] 96344094 8296007 7611429 71683658 10647204 61619286 74017762 #> [197] 11520309 15147284 14298547 8412275 15423107 41462424 10791906 #> [204] 9151941 18486986 48871700 6667562 108987996 95606834 75976912 #> [211] 8886563 26979609 9254230 16704633 14933422 7564036 20839109 #> [218] 21573744 35682696 6442671 8149179 11528409 18516693 9384789 #> [225] 65518656 144587180 11697577 8498735 313114558 95098003 6923534 #> [232] 7349065 416056048 43022313 11601109 60111927 9447360 9707172 #> [239] 8503372 41214557 29059868 28027898 26118507 18888369 44649293 #> [246] 75976912 12094008 40925932 10694025 13821511 16911118 7180452 #> [253] 9573738 7749935 8492878 27312355 14219627 14270231 14559481 #> [260] 19692228 6336718 6361251 19465000 9281419 11511254 16997600 #> [267] 7548717 11842030 55551482 65250849 145945230 32570583 8211775 #> [274] 8061524 7650210 7711045 9594556 28758152 28682165 14944211 #> [281] 12867027 6429295 14734836 43069044 8113889 9467249 19698589 #> [288] 36069079 107325831 96350533 8291875 7681710 72870063 11596942 #> [295] 62753296 71221052 12133963 16707056 19516231 34945784 50742865 #> [302] 9556854 8232783 7931089 32738024 7170241 109494501 108982337 #> [309] 8951308 27803996 9831205 6559072 8630552 9518918 12182698 #> [316] 19913773 23525724 37908393 6748793 8338938 11248192 17316297 #> [323] 10298558 73994670 157281407 12389663 289168472 95819556 443820452 #> [330] 43490536 11718553 50406451 9212583 9070670 8582220 45789971 #> [337] 16350747 35936905 28755830 29325167 26472486 16328706 44591952 #> [344] 7078653 76894541 13459454 17988626 17068454 7550438 9601312 #> [351] 7131311 7527026 8023070 12988774 15291711 20019856 7887333 #> [358] 9061253 42488820 6278599 106600000 106600000 6321144 74205453 #> [365] 8563507 27098674 9527584 8410000 9645361 32516207 35473178 #> [372] 7438509 19620000 22793581 38257290 15700000 15700000 6938104 #> [379] 8647934 21942700 18767800 62096462 150366755 11976082 302630700 #> [386] 99531000 6296935 6323365 445668500 30729000 11539452 52112562 #> [393] 9606871 7152589 7659254 28577000 28505884 27210190 17145026 #> [400] 47359815 44358707 7445345 74205453 12515496 30567335 17883107 #> [407] 14753898 17208572 10795573 7283336 6359131 6359131 9524698 #> [414] 7651101 12082821 14624352 19552939 14274353 8460665 14967690 #> [421] 32037093 7047285 109330960 110619219 8712193 28185790 10291308 #> [428] 12602023 9124364 35437352 36771072 11812797 21330672 25827642 #> [435] 40194420 13000000 12086663 6924704 8592203 23921327 16787270 #> [442] 64852509 157258424 12604759 304915334 97770261 399611656 26659809 #> [449] 12082172 61017441 9002204 8056023 7463672 14795995 49379074 #> [456] 29309548 29309767 23814062 19620195 44988779 7560474 49403490 #> [463] 7794936 7823306 78822268 18197334 15321408 16024642 8908068 #> [470] 7583924 9638579 6782063 7694649 8083324 13103852 15445343 #> [477] 19248806 7961957 9059575 42488820 106600000 106600000 6320856 #> [484] 75322844 8589859 27335205 9599403 8410000 9645361 35223117 #> [491] 38180626 7432089 19620000 23299566 39270917 15700000 15700000 #> [498] 7388104 9203283 21498200 18582200 62096462 150316817 12078119 #> [505] 308053700 101300000 6285822 457670000 31591000 11515555 51961034 #> [512] 9693376 7152589 7652225 28577000 28508825 27363825 17570173 #> [519] 49410188 46383602 7440827 75322844 12463324 30191083 15424498 #> [526] 14753510 16983839 11018116 7308625 9618959 7699594 13103852 #> [533] 15445343 19998806 7961957 9059575 35488820 106600000 106600000 #> [540] 6320856 8589859 27335205 9599403 8410000 9645361 35223117 #> [547] 38180626 7432089 19620000 23299566 40270917 15700000 15700000 #> [554] 7388104 9203283 21498200 18582200 69656462 156316817 12078119 #> [561] 331003700 100400000 435655000 28755000 11515555 51961034 9693376 #> [568] 7152589 7652225 12463324 30191083 28577000 28508825 27363825 #> [575] 17570173 49410188 45483602 7440827 75322844 22924498 14753510 #> [582] 16983839 11018116 7308625 9618959 6285822 7699594 13135244 #> [589] 14468816 19522706 9907564 9076656 27073300 6502027 6614231 #> [596] 6405401 26132416 10602865 10200000 10200000 40111668 42680556 #> [603] 7322133 17000000 29463203 48579051 14000000 14000000 7813157 #> [610] 9668938 17602400 17313750 76783000 165526545 12588831 328411700 #> [617] 104340000 8000000 8000000 14298578 452672000 29800000 11854075 #> [624] 56146764 9758016 8632079 8847206 12851331 36907213 28720000 #> [631] 29901313 27892496 25618403 57395898 49222354 7192219 15719991 #> [638] 90615528 35663564 37130172 14955643 17408080 9883079 7662590 #> [645] 9829835 7979237 13192499 14551733 19727596 10038848 9065620 #> [652] 29073300 6481409 6771455 8060264 27895044 10662239 10200000 #> [659] 10200000 43616676 46180981 7317975 17000000 29903001 49230417 #> [666] 14000000 14000000 7878157 9841404 16703300 16900350 82438000 #> [673] 169526607 12656697 342011700 109500000 8500000 8500000 16907566 #> [680] 471217000 30700000 7655650 46929865 9670258 8632079 8806558 #> [687] 12751331 36174699 29150350 30329122 27999342 24110830 58117139 #> [694] 52304122 7169072 15722659 92026785 40368011 47907967 15105314 #> [701] 17358751 10029517 7694425 9857222 7961091 13289331 14634895 #> [708] 19784896 10178979 9059955 29073300 6546081 6823657 8516304 #> [715] 28492934 10719037 10200000 10200000 47519935 50104962 7321281 #> [722] 17000000 30375284 50248645 14000000 14000000 7943157 9964601 #> [729] 16447700 15454750 87228000 170526670 12720597 337100000 113800000 #> [736] 8700000 8700000 16972176 485776000 31450000 7348741 46551262 #> [743] 9713286 8632079 8866802 12653431 37574506 29590000 30761116 #> [750] 28044838 24007154 59669867 54378884 7149383 15726703 93593111 #> [757] 40367444 47910635 15152281 17270486 10179665 7726113 9887265 #> [764] 7990620 13410995 14733455 19912696 10293606 9045374 29073300 #> [771] 6560520 6888731 8479445 28613161 10766039 10200000 10200000 #> [778] 51692040 54317430 7332624 17000000 31128833 51574086 14000000 #> [785] 14000000 8008157 10109881 16012300 14770150 88582500 174096670 #> [792] 12797649 334600000 118300000 17047088 500075000 32250000 7340195 #> [799] 46580903 9777372 8621723 8966708 12653431 37691678 30030000 #> [806] 31204139 28135091 12000000 15219900 23496842 59788312 55378525 #> [813] 7142205 15536988 95008030 40367364 47922965 15150019 17209209 #> [820] 10266524 7759709 9964576 8038269 13534788 14839665 20041016 #> [827] 10408697 9031622 29073300 6665867 6950209 8452604 28772440 #> [834] 10833112 10200000 10200000 56244145 58912067 7344731 17000000 #> [841] 32256372 52911965 14000000 14000000 8078157 10381436 15643500 #> [848] 14743950 88582500 174176670 12878432 331000000 122900000 17125210 #> [855] 507995000 17750000 7335597 46642336 9850728 8620787 9070656 #> [862] 12653431 38961869 30480000 31652396 28277698 12000000 15268200 #> [869] 23336027 60466128 56409617 7146246 15536777 96640834 40367364 #> [876] 47936039 15148603 17269689 10355394 7819672 9948306 8091701 #> #> $n #> [1] 6225 #>