Biology, images, analysis, design...
Use/Abuse Principles How To Related
"It has long been an axiom of mine that the little things are infinitely the most important" (Sherlock Holmes)

Search this site



Just a note

  • If your data contains any missing values, coded as NA (for Not Available), their mean will also be Not Available - unless you instruct R to remove them before calculating the mean. For example, mean(c(12.1, NA, 31.8, NA)) is NA, whereas mean(c(12.1, NA, 31.8, NA), na.rm = TRUE) is 21.95

  • [1] before the output indicates this result is the first item of a list - even though, in this case, the list only contains one item.

    Notice also that the mean function can also calculate 'trimmed' means.

    For example mean(y, trim = 0.5) calculates the mean of variable y, having removed the larger half and smaller half of its observations. In other words mean(y, trim = 0.5) produces exactly the same result as median(y).

    Trimmed means are considered further in Unit 2.