Showing the contents of a variable

By putting the name of a variable on a line by itself, it will display the contents of that variable when the chunk is run. This variable is built in to R, meaning that you don’t have to import it first.

this variable is an array, which is really just a list of numbers in this case.

rivers
##   [1]  735  320  325  392  524  450 1459  135  465  600  330  336  280  315
##  [15]  870  906  202  329  290 1000  600  505 1450  840 1243  890  350  407
##  [29]  286  280  525  720  390  250  327  230  265  850  210  630  260  230
##  [43]  360  730  600  306  390  420  291  710  340  217  281  352  259  250
##  [57]  470  680  570  350  300  560  900  625  332 2348 1171 3710 2315 2533
##  [71]  780  280  410  460  260  255  431  350  760  618  338  981 1306  500
##  [85]  696  605  250  411 1054  735  233  435  490  310  460  383  375 1270
##  [99]  545  445 1885  380  300  380  377  425  276  210  800  420  350  360
## [113]  538 1100 1205  314  237  610  360  540 1038  424  310  300  444  301
## [127]  268  620  215  652  900  525  246  360  529  500  720  270  430  671
## [141] 1770

using the ‘length’ function to indicate how many elements are in the array

length(rivers)
## [1] 141

##using the ‘summary’ function to show key statistics about the list

summary(rivers)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##   135.0   310.0   425.0   591.2   680.0  3710.0

using the ‘hist’ function to display a histogram using a parameter called breaks to indicate 100 buckets

hist(rivers, breaks=100)