1.10) Understanding Functions
G. To find out more about any function, the quickest way is to put ?
in front and omit the brackets. It’s important to check the usage of functions, because most can take more than one argument to fine-tune their functioning – not necessarily a sequence of data values. So, for example, mean(1,3,5)
probably doesn’t do what you were expecting because only the first argument (bit before the first comma) is meant for data; rather provide all the data as a single vector object by typing: mean(c(1,3,5))
.
We put brackets after a function because we want to use the function, not look at it. Functions are still objects, so if you forget to put brackets after a function name, you may get to see the code behind that function. (R is open-source software, so nothing has to be hidden – although its basic functions are mostly written in C.) Try just typing: cor
.