################################################################################
#### Module 3, Lesson about Vectors, Basic Functions, Data Frames, and Help ####
################################################################################
# Lesson 5, part 1: Some useful functions


################################### 
##### SUMMARY FUNCTIONS 
# Basic essential functions to apply to vectors that you will be using a lot
# mean, max, min, length, unique, table, summary

# Define a vector to work with:
vect1 <- c(4,64,4,68,43,18,6,2,2,2,21,68,7,21,33,1,74)

mean(vect1)
max(vect1)
min(vect1)
length(vect1)
unique(vect1)
table(vect1)
summary(vect1)

vect2 <- c("A","A","C","T","A","C","G")

table(vect2)

vect3 <- c(2,4,6,3,1,NA,43,6)

mean(vect3, na.rm=T)

###################################
##### SAMPLING FUNCTIONS
# Sometimes we need to pick random values from a vector 
# sample, rnorm, runif

sample(vect1, size=5)

rnorm(n=5)

runif(n=5, min=5, max=6)

###################################
##### SORTING FUNCTIONS
# Functions for sorting and finding the order of vectors:
# sort, order

sort(vect1, decreasing=T)
# vect1 <- sort(vect1, decreasing=T)

order(vect1)



###################################
##### SUMMARY
# - functions for summarizing vectors
# - functions for sampling vectors
# - functions for sorting vectors

