1 [[!meta title="Learning R: Basic Variables and Objects"]]
6 Like most computer languages, R uses variables as a means of storing
7 information in memory and retrieving it later. Variables can be
8 assigned to using the `<-` or `=` operator. For example, to assign the
9 number `5` to the variable `foo`, you would write
11 [[!sweavealike echo=1 results="hide" code="""
15 Variables can retrieved simply by referring to them by name. For
16 example, to add `8` to the variable `foo` and store the result in
17 `bar`, you would do the following:
19 [[!sweavealike echo=1 results="hide" code="""
24 In R, variables are more correctly called objects, because they have
25 structure and do not directly refer to a specific memory location.
33 A vector is the major data type used in R. You can think of it as a
34 line of cells, each containing a value of the same type.
35 [Type here means a number or a string.]