Читать книгу The Big R-Book - Philippe J. S. De Brouwer - Страница 23

Function use for mean()

Оглавление

mean (x, na.rm = FALSE, trim = 0, …)

Where

 x is an R-object,

 na.rm is a boolean (setting this to TRUE will remove missing values),

 trim is the fraction of observations to be removed on both sides of the distribution before the mean is computed – the default is 0 and it cannot be higher than 0.5

From this example, it should be clear how the function mean() is used. Note the following:

 The name of the function is in the title.

 On the first line we repeat the function with its most important parameters.

 The parameter x is an obligatory parameter.

 The parameter na.rm can be omitted. When it is not provided, the default FALSE is used. A parameter with a default can be recognised in the first line via the equal sign.

 The three dots indicate that other parameters can be passed that will not be used by the function mean(), but they are passed on to further methods.

 Some functions can take a lot of parameters. In some cases, we only show the most important ones.

Later on in the book, we assume that the reader is able to use the examples and find more about the function in its documentation. For example, ?mean will display information about the function mean.

When a new concept or idea is built up with examples they generally appear just like that in the text. Additional examples after the point is made are usually highlighed as follows:

The Big R-Book

Подняться наверх