0. The Basics of R: Using R
Working with vectors
The following video explains how you can work not just with single numbers but with collections of numbers (so-called vectors). This makes it possible to do many operations on your data in an efficient way.
You should watch the video and repeat all the steps that are explained yourself in RStudio.
Keypoints
You are now familiar with:
- creating a vector with numbers, using the
c( )
function - doing calculations to all numbers in a vector at once
- applying logical statements (
>
, >=,<
, <=,==
,!=
) to vectors, which returns a vector with logical values (TRUE or FALSE) - applying the functions
mean()
,length()
andsum()
to vectors - the use of square brackets (
[ ]
) to select certain elements from a vector, either by pointing to a specific element (e.g.x[3]
), several elements (e.g.x[c(3,4)]
), or by using a logical statement (e.g.x[x>0]
)
Unlock full access