boxplot-example.nlogo 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582
  1. ;; Boxplot example of R-extension
  2. ;;
  3. ;;
  4. ;; by Jan C. Thiele
  5. ;; University of Goettingen, Germany
  6. ;; Department Ecoinformatics, Biometrics and Forest Growth
  7. ;; Buesgenweg 4
  8. ;; 37077 Goettingen
  9. ;; Germany
  10. ;;
  11. ;; Contact: jthiele@gwdg.de
  12. ;;
  13. ;; Copyright: 2011, J.C. Thiele
  14. extensions [r]
  15. to activate-JavaGD-plot-device
  16. clear-all
  17. r:setPlotDevice
  18. reset-ticks
  19. ; this model doesn't use ticks, but this disables the buttons until after
  20. ; this procedure has been run
  21. end
  22. to test
  23. ;a new empty local list
  24. let mylist []
  25. ; fill the list with 50 random values
  26. repeat 50 [
  27. set mylist fput random-normal 10 20 mylist
  28. ]
  29. ; show the list in the Command Center
  30. print mylist
  31. ; send the list into a new R dataframe (with one column named v1)
  32. (r:putdataframe "df1" "v1" mylist)
  33. ; create a boxplot of the dataframe.
  34. ; since the dataframe has just one column, there is just one box.
  35. r:eval "boxplot(df1)"
  36. end
  37. to test2
  38. ;two new empty local lists
  39. let mylist1 []
  40. let mylist2 []
  41. ; fill the list with 50 random values
  42. repeat 50 [
  43. set mylist1 fput random-normal 10 20 mylist1
  44. set mylist2 fput random-normal 15 15 mylist2
  45. ]
  46. ; send the list into a new R dataframe (with one column named v1)
  47. (r:putdataframe "df1" "v1" mylist1 "v2" mylist2)
  48. ; create a boxplot of the dataframe.
  49. ; since the dataframe has just one column, there is just one box.
  50. r:eval "boxplot(df1)"
  51. end
  52. ;; copied from the plot example...
  53. to dev-off
  54. r:eval "dev.off()"
  55. end
  56. to r-idle ;; a "forever" method
  57. r:eval "Sys.sleep(0.01)"
  58. end
  59. @#$#@#$#@
  60. GRAPHICS-WINDOW
  61. 463
  62. 10
  63. 647
  64. 195
  65. -1
  66. -1
  67. 5.333333333333333
  68. 1
  69. 10
  70. 1
  71. 1
  72. 1
  73. 0
  74. 1
  75. 1
  76. 1
  77. -16
  78. 16
  79. -16
  80. 16
  81. 0
  82. 0
  83. 1
  84. ticks
  85. 30.0
  86. BUTTON
  87. 20
  88. 181
  89. 83
  90. 214
  91. NIL
  92. test
  93. NIL
  94. 1
  95. T
  96. OBSERVER
  97. NIL
  98. NIL
  99. NIL
  100. NIL
  101. 0
  102. BUTTON
  103. 18
  104. 339
  105. 91
  106. 372
  107. NIL
  108. dev-off
  109. NIL
  110. 1
  111. T
  112. OBSERVER
  113. NIL
  114. NIL
  115. NIL
  116. NIL
  117. 0
  118. BUTTON
  119. 20
  120. 100
  121. 83
  122. 133
  123. NIL
  124. r-idle
  125. T
  126. 1
  127. T
  128. OBSERVER
  129. NIL
  130. NIL
  131. NIL
  132. NIL
  133. 1
  134. TEXTBOX
  135. 21
  136. 55
  137. 435
  138. 102
  139. activate this button, if you want to have the R plot window active (this will create an empty loop for R, that it will stay active). If you want to save the boxplot in a file without seeing it in the R window, you don't need this button.
  140. 11
  141. 0.0
  142. 1
  143. TEXTBOX
  144. 21
  145. 147
  146. 442
  147. 176
  148. this button will create a temp. list, send it to R and creates a boxplot (into the standard grafics output -> the R Plot Window).
  149. 11
  150. 0.0
  151. 1
  152. TEXTBOX
  153. 18
  154. 309
  155. 439
  156. 336
  157. this button will close the graphics device (here: the plot window). But you can also just close the window.
  158. 11
  159. 0.0
  160. 1
  161. TEXTBOX
  162. 22
  163. 228
  164. 440
  165. 261
  166. this button will create two temp. lists, put them both into one R data.frame and creates a boxplot over both columns.
  167. 11
  168. 0.0
  169. 1
  170. BUTTON
  171. 20
  172. 262
  173. 83
  174. 295
  175. NIL
  176. test2
  177. NIL
  178. 1
  179. T
  180. OBSERVER
  181. NIL
  182. NIL
  183. NIL
  184. NIL
  185. 0
  186. BUTTON
  187. 23
  188. 14
  189. 212
  190. 47
  191. NIL
  192. activate-JavaGD-plot-device
  193. NIL
  194. 1
  195. T
  196. OBSERVER
  197. NIL
  198. NIL
  199. NIL
  200. NIL
  201. 1
  202. @#$#@#$#@
  203. ## WHAT IS IT?
  204. This section could give a general understanding of what the model is trying to show or explain.
  205. ## HOW IT WORKS
  206. This section could explain what rules the agents use to create the overall behavior of the model.
  207. ## HOW TO USE IT
  208. This section could explain how to use the model, including a description of each of the items in the interface tab.
  209. ## THINGS TO NOTICE
  210. This section could give some ideas of things for the user to notice while running the model.
  211. ## THINGS TO TRY
  212. This section could give some ideas of things for the user to try to do (move sliders, switches, etc.) with the model.
  213. ## EXTENDING THE MODEL
  214. This section could give some ideas of things to add or change in the procedures tab to make the model more complicated, detailed, accurate, etc.
  215. ## NETLOGO FEATURES
  216. This section could point out any especially interesting or unusual features of NetLogo that the model makes use of, particularly in the Procedures tab. It might also point out places where workarounds were needed because of missing features.
  217. ## RELATED MODELS
  218. This section could give the names of models in the NetLogo Models Library or elsewhere which are of related interest.
  219. ## CREDITS AND REFERENCES
  220. This section could contain a reference to the model's URL on the web if it has one, as well as any other necessary credits or references.
  221. @#$#@#$#@
  222. default
  223. true
  224. 0
  225. Polygon -7500403 true true 150 5 40 250 150 205 260 250
  226. airplane
  227. true
  228. 0
  229. Polygon -7500403 true true 150 0 135 15 120 60 120 105 15 165 15 195 120 180 135 240 105 270 120 285 150 270 180 285 210 270 165 240 180 180 285 195 285 165 180 105 180 60 165 15
  230. arrow
  231. true
  232. 0
  233. Polygon -7500403 true true 150 0 0 150 105 150 105 293 195 293 195 150 300 150
  234. box
  235. false
  236. 0
  237. Polygon -7500403 true true 150 285 285 225 285 75 150 135
  238. Polygon -7500403 true true 150 135 15 75 150 15 285 75
  239. Polygon -7500403 true true 15 75 15 225 150 285 150 135
  240. Line -16777216 false 150 285 150 135
  241. Line -16777216 false 150 135 15 75
  242. Line -16777216 false 150 135 285 75
  243. bug
  244. true
  245. 0
  246. Circle -7500403 true true 96 182 108
  247. Circle -7500403 true true 110 127 80
  248. Circle -7500403 true true 110 75 80
  249. Line -7500403 true 150 100 80 30
  250. Line -7500403 true 150 100 220 30
  251. butterfly
  252. true
  253. 0
  254. Polygon -7500403 true true 150 165 209 199 225 225 225 255 195 270 165 255 150 240
  255. Polygon -7500403 true true 150 165 89 198 75 225 75 255 105 270 135 255 150 240
  256. Polygon -7500403 true true 139 148 100 105 55 90 25 90 10 105 10 135 25 180 40 195 85 194 139 163
  257. Polygon -7500403 true true 162 150 200 105 245 90 275 90 290 105 290 135 275 180 260 195 215 195 162 165
  258. Polygon -16777216 true false 150 255 135 225 120 150 135 120 150 105 165 120 180 150 165 225
  259. Circle -16777216 true false 135 90 30
  260. Line -16777216 false 150 105 195 60
  261. Line -16777216 false 150 105 105 60
  262. car
  263. false
  264. 0
  265. Polygon -7500403 true true 300 180 279 164 261 144 240 135 226 132 213 106 203 84 185 63 159 50 135 50 75 60 0 150 0 165 0 225 300 225 300 180
  266. Circle -16777216 true false 180 180 90
  267. Circle -16777216 true false 30 180 90
  268. Polygon -16777216 true false 162 80 132 78 134 135 209 135 194 105 189 96 180 89
  269. Circle -7500403 true true 47 195 58
  270. Circle -7500403 true true 195 195 58
  271. circle
  272. false
  273. 0
  274. Circle -7500403 true true 0 0 300
  275. circle 2
  276. false
  277. 0
  278. Circle -7500403 true true 0 0 300
  279. Circle -16777216 true false 30 30 240
  280. cow
  281. false
  282. 0
  283. Polygon -7500403 true true 200 193 197 249 179 249 177 196 166 187 140 189 93 191 78 179 72 211 49 209 48 181 37 149 25 120 25 89 45 72 103 84 179 75 198 76 252 64 272 81 293 103 285 121 255 121 242 118 224 167
  284. Polygon -7500403 true true 73 210 86 251 62 249 48 208
  285. Polygon -7500403 true true 25 114 16 195 9 204 23 213 25 200 39 123
  286. cylinder
  287. false
  288. 0
  289. Circle -7500403 true true 0 0 300
  290. dot
  291. false
  292. 0
  293. Circle -7500403 true true 90 90 120
  294. face happy
  295. false
  296. 0
  297. Circle -7500403 true true 8 8 285
  298. Circle -16777216 true false 60 75 60
  299. Circle -16777216 true false 180 75 60
  300. Polygon -16777216 true false 150 255 90 239 62 213 47 191 67 179 90 203 109 218 150 225 192 218 210 203 227 181 251 194 236 217 212 240
  301. face neutral
  302. false
  303. 0
  304. Circle -7500403 true true 8 7 285
  305. Circle -16777216 true false 60 75 60
  306. Circle -16777216 true false 180 75 60
  307. Rectangle -16777216 true false 60 195 240 225
  308. face sad
  309. false
  310. 0
  311. Circle -7500403 true true 8 8 285
  312. Circle -16777216 true false 60 75 60
  313. Circle -16777216 true false 180 75 60
  314. Polygon -16777216 true false 150 168 90 184 62 210 47 232 67 244 90 220 109 205 150 198 192 205 210 220 227 242 251 229 236 206 212 183
  315. fish
  316. false
  317. 0
  318. Polygon -1 true false 44 131 21 87 15 86 0 120 15 150 0 180 13 214 20 212 45 166
  319. Polygon -1 true false 135 195 119 235 95 218 76 210 46 204 60 165
  320. Polygon -1 true false 75 45 83 77 71 103 86 114 166 78 135 60
  321. Polygon -7500403 true true 30 136 151 77 226 81 280 119 292 146 292 160 287 170 270 195 195 210 151 212 30 166
  322. Circle -16777216 true false 215 106 30
  323. flag
  324. false
  325. 0
  326. Rectangle -7500403 true true 60 15 75 300
  327. Polygon -7500403 true true 90 150 270 90 90 30
  328. Line -7500403 true 75 135 90 135
  329. Line -7500403 true 75 45 90 45
  330. flower
  331. false
  332. 0
  333. Polygon -10899396 true false 135 120 165 165 180 210 180 240 150 300 165 300 195 240 195 195 165 135
  334. Circle -7500403 true true 85 132 38
  335. Circle -7500403 true true 130 147 38
  336. Circle -7500403 true true 192 85 38
  337. Circle -7500403 true true 85 40 38
  338. Circle -7500403 true true 177 40 38
  339. Circle -7500403 true true 177 132 38
  340. Circle -7500403 true true 70 85 38
  341. Circle -7500403 true true 130 25 38
  342. Circle -7500403 true true 96 51 108
  343. Circle -16777216 true false 113 68 74
  344. Polygon -10899396 true false 189 233 219 188 249 173 279 188 234 218
  345. Polygon -10899396 true false 180 255 150 210 105 210 75 240 135 240
  346. house
  347. false
  348. 0
  349. Rectangle -7500403 true true 45 120 255 285
  350. Rectangle -16777216 true false 120 210 180 285
  351. Polygon -7500403 true true 15 120 150 15 285 120
  352. Line -16777216 false 30 120 270 120
  353. leaf
  354. false
  355. 0
  356. Polygon -7500403 true true 150 210 135 195 120 210 60 210 30 195 60 180 60 165 15 135 30 120 15 105 40 104 45 90 60 90 90 105 105 120 120 120 105 60 120 60 135 30 150 15 165 30 180 60 195 60 180 120 195 120 210 105 240 90 255 90 263 104 285 105 270 120 285 135 240 165 240 180 270 195 240 210 180 210 165 195
  357. Polygon -7500403 true true 135 195 135 240 120 255 105 255 105 285 135 285 165 240 165 195
  358. line
  359. true
  360. 0
  361. Line -7500403 true 150 0 150 300
  362. line half
  363. true
  364. 0
  365. Line -7500403 true 150 0 150 150
  366. pentagon
  367. false
  368. 0
  369. Polygon -7500403 true true 150 15 15 120 60 285 240 285 285 120
  370. person
  371. false
  372. 0
  373. Circle -7500403 true true 110 5 80
  374. Polygon -7500403 true true 105 90 120 195 90 285 105 300 135 300 150 225 165 300 195 300 210 285 180 195 195 90
  375. Rectangle -7500403 true true 127 79 172 94
  376. Polygon -7500403 true true 195 90 240 150 225 180 165 105
  377. Polygon -7500403 true true 105 90 60 150 75 180 135 105
  378. plant
  379. false
  380. 0
  381. Rectangle -7500403 true true 135 90 165 300
  382. Polygon -7500403 true true 135 255 90 210 45 195 75 255 135 285
  383. Polygon -7500403 true true 165 255 210 210 255 195 225 255 165 285
  384. Polygon -7500403 true true 135 180 90 135 45 120 75 180 135 210
  385. Polygon -7500403 true true 165 180 165 210 225 180 255 120 210 135
  386. Polygon -7500403 true true 135 105 90 60 45 45 75 105 135 135
  387. Polygon -7500403 true true 165 105 165 135 225 105 255 45 210 60
  388. Polygon -7500403 true true 135 90 120 45 150 15 180 45 165 90
  389. sheep
  390. false
  391. 0
  392. Rectangle -7500403 true true 151 225 180 285
  393. Rectangle -7500403 true true 47 225 75 285
  394. Rectangle -7500403 true true 15 75 210 225
  395. Circle -7500403 true true 135 75 150
  396. Circle -16777216 true false 165 76 116
  397. square
  398. false
  399. 0
  400. Rectangle -7500403 true true 30 30 270 270
  401. square 2
  402. false
  403. 0
  404. Rectangle -7500403 true true 30 30 270 270
  405. Rectangle -16777216 true false 60 60 240 240
  406. star
  407. false
  408. 0
  409. Polygon -7500403 true true 151 1 185 108 298 108 207 175 242 282 151 216 59 282 94 175 3 108 116 108
  410. target
  411. false
  412. 0
  413. Circle -7500403 true true 0 0 300
  414. Circle -16777216 true false 30 30 240
  415. Circle -7500403 true true 60 60 180
  416. Circle -16777216 true false 90 90 120
  417. Circle -7500403 true true 120 120 60
  418. tree
  419. false
  420. 0
  421. Circle -7500403 true true 118 3 94
  422. Rectangle -6459832 true false 120 195 180 300
  423. Circle -7500403 true true 65 21 108
  424. Circle -7500403 true true 116 41 127
  425. Circle -7500403 true true 45 90 120
  426. Circle -7500403 true true 104 74 152
  427. triangle
  428. false
  429. 0
  430. Polygon -7500403 true true 150 30 15 255 285 255
  431. triangle 2
  432. false
  433. 0
  434. Polygon -7500403 true true 150 30 15 255 285 255
  435. Polygon -16777216 true false 151 99 225 223 75 224
  436. truck
  437. false
  438. 0
  439. Rectangle -7500403 true true 4 45 195 187
  440. Polygon -7500403 true true 296 193 296 150 259 134 244 104 208 104 207 194
  441. Rectangle -1 true false 195 60 195 105
  442. Polygon -16777216 true false 238 112 252 141 219 141 218 112
  443. Circle -16777216 true false 234 174 42
  444. Rectangle -7500403 true true 181 185 214 194
  445. Circle -16777216 true false 144 174 42
  446. Circle -16777216 true false 24 174 42
  447. Circle -7500403 false true 24 174 42
  448. Circle -7500403 false true 144 174 42
  449. Circle -7500403 false true 234 174 42
  450. turtle
  451. true
  452. 0
  453. Polygon -10899396 true false 215 204 240 233 246 254 228 266 215 252 193 210
  454. Polygon -10899396 true false 195 90 225 75 245 75 260 89 269 108 261 124 240 105 225 105 210 105
  455. Polygon -10899396 true false 105 90 75 75 55 75 40 89 31 108 39 124 60 105 75 105 90 105
  456. Polygon -10899396 true false 132 85 134 64 107 51 108 17 150 2 192 18 192 52 169 65 172 87
  457. Polygon -10899396 true false 85 204 60 233 54 254 72 266 85 252 107 210
  458. Polygon -7500403 true true 119 75 179 75 209 101 224 135 220 225 175 261 128 261 81 224 74 135 88 99
  459. wheel
  460. false
  461. 0
  462. Circle -7500403 true true 3 3 294
  463. Circle -16777216 true false 30 30 240
  464. Line -7500403 true 150 285 150 15
  465. Line -7500403 true 15 150 285 150
  466. Circle -7500403 true true 120 120 60
  467. Line -7500403 true 216 40 79 269
  468. Line -7500403 true 40 84 269 221
  469. Line -7500403 true 40 216 269 79
  470. Line -7500403 true 84 40 221 269
  471. x
  472. false
  473. 0
  474. Polygon -7500403 true true 270 75 225 30 30 225 75 270
  475. Polygon -7500403 true true 30 75 75 30 270 225 225 270
  476. @#$#@#$#@
  477. NetLogo 6.0
  478. @#$#@#$#@
  479. @#$#@#$#@
  480. @#$#@#$#@
  481. @#$#@#$#@
  482. @#$#@#$#@
  483. default
  484. 0.0
  485. -0.2 0 0.0 1.0
  486. 0.0 1 1.0 0.0
  487. 0.2 0 0.0 1.0
  488. link direction
  489. true
  490. 0
  491. Line -7500403 true 150 150 90 180
  492. Line -7500403 true 150 150 210 180
  493. @#$#@#$#@
  494. 0
  495. @#$#@#$#@