Вы находитесь на странице: 1из 2

R PROGRAMMING LANGUAGE

Firstly, make sure that you know the distinction between your response variable and

your explanatory variable.

Then, you need to select the kind of statistics you need to employ:

(1) If your response variable is a count, where you typically have lots of zeros, then you

will want to use either:

a) the classical tests

b) count data in tables.

(2) If your response variable is a continuous measure (e.g., a weight), then you will

want to use either:

a) regression if your explanatory variable is continuous (e.g., an altitude);

b) analysis of variance if your explanatory variable is categorical (e.g.,

genotype).

Do not forget to use the appropriate graphics:

a) scatter plots for regression;

b) box and whisker plots for ANOVA.


Recognising mathematical functions is straightforward: names + the fact that
their arguments are enclosed in round brackets ().

Subscripts on objects have square brackets [].

Multi-line blocks of R code are enclosed within curly brackets {}.

Elements within lists have double square brackets [[]].

Type CTRL + S to save the contents of R editor window and name it.

Factors are categorical variables that have a fixed number of levels. A simple
example might be a variable called gender with two levels: female and male.
In statistical modelling, factors are associated with analysis of variance (all of
the explanatory variables are categorical) and analysis of covariance (some of the
explanatory variables are categorical and some are continuous).

To create a dataframe, use data <-; the function data.frame() creates data frames,
tightly coupled collections of variables which share many of the properties of
matrices and lists, used as the fundamental data structure by R.

The function factor is used to encode a vector as a factor (the terms category and
enumerated type are also used for this). Vector as character strings. A factor can be
compared to another factor with an identical set of levels (although not necessarily in
the same ordering). To turn factor levels into integers, use the unclass function.
Factors are stored internally as integers, so their mode=numeric.

Вам также может понравиться