-
Notifications
You must be signed in to change notification settings - Fork 10
/
vectors1.R
40 lines (24 loc) · 1.04 KB
/
vectors1.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# Vectors 1
# we're going to do some random draws, so set the
# random seed so we get the same results each time (starts random sequence in same place)
set.seed(1234)
# Vector with 5 random (normal) values
x1 <- rnorm(5)
x1
# Which values in x1 are less than 0?
# Compare x1 to 0
# Create another vector named x2 with 5 random (normal) values in it
# (copy and modify the code in line 9 above)
# drawn from distribution with mean 0.5;
# look in the distributions section on the reference card
# https://cran.r-project.org/doc/contrib/Baggott-refcard-v2.pdf
# or the help for the rnorm function
# to see how to specify the mean (it's another argument to rnorm())
# Compare the maximum values of each vector;
# Is the max of x1 greater than x2?
# look in the Math section of the reference card for the function name
# to get the maximum
# Compare the mean values of each vector;
# Is the mean of x1 greater than x2?
# look in the Math section of the reference card for function name
# Add the values 2, 3, and 4 to the end of x1, look at the result