c(1, NULL, 3)
8 Vectors
8.1 Quiz: Vectors I
To create the following sequence of numbers
0.2, 0.4, 0.6, ..., 1.2
we can use:
✗0.2:1.2
✗seq(0.2, 1.2)
✓seq(0.2, 1.2, by = 0.2)
✓seq(0.2, 1.2, length.out = 6)
8.2 Quiz: Vectors II
What is the result of executing:
✗NULL
✓1, 3
✗1, NULL, 3
✗1, NA, 3
8.3 Exercise: Vectors III
<- c(1, 3)
x x
[1] 1 3
What happens when you try to combine NULL
to x
?
Why?
8.4 Exercise: Vectors IV
Calculate the variance of the sequence of integer numbers from 1 to 10, and assign the result to the variable a.
If you need search the help for variance to identify the function to use.
8.5 Exercise: Vectors V
# y contains 20 random numbers from a Normal distribution
# with zero mean and standard deviation 1
set.seed(123)
<- rnorm(20)
y y
[1] -0.56047565 -0.23017749 1.55870831 0.07050839 0.12928774 1.71506499
[7] 0.46091621 -1.26506123 -0.68685285 -0.44566197 1.22408180 0.35981383
[13] 0.40077145 0.11068272 -0.55584113 1.78691314 0.49785048 -1.96661716
[19] 0.70135590 -0.47279141
Filter all observations from y that are greater than or equal to 0.5, and attribute the result to the variable fy.