################################################################################
#### Module 3, Lesson about Vectors, Basic Functions, Data Frames, and Help ####
################################################################################
# Lesson 4, part 2: Creating and indexing vectors 


###################################
##### CREATING NUMBER SEQUENCES
# Of course you can type in values manually to create vectors
# as we have been doing, but there are some easier way to do this:
apples <- c(1,2,3,4,5)
apples = 1:5

rep(x=c(1,2,3), times=10)

rep(2, 10)

seq(from=1, to=20, by=2)
seq(from=0, to=1, by=0.1)

seq(1,10,1)
1:10
rep(c(1:10), 1)



###################################
##### VECTOR INDEXING
# Indexing refers to being able to select particular values or
# subsets of values from vectors. Indexing is done with square
# brackets '[]' and is quite intuitive once you get the hang of it.

diam_cm <- c(12,18,32,8,23,26,21,18)
diam_cm[c(1, 3, 4)]
diam_cm[1:3]

diam_cm[c(1:3, 6:8)]

diam_cm[-c(2,3)]

diam_cm <- diam_cm[c(5,6)]

diam_cm <- c(12,18,32,8,23,26,21,18)
diam_cm_clean <- diam_cm[-5]


###################################
##### SUMMARY
# - Creating vectors more easily with the ':', rep, and seq
#   functions
# - Indexing vectors




