################################################################################
#### Module 3, Lesson about Vectors, Basic Functions, Data Frames, and Help ####
################################################################################
### EXCERCISES (Lessons 4, 5, 6)

# 1) Define a variable named "my_var" with a vector of sequential numbers from 20 to 35:


# 2) Use another method to do the same thing


# 3) Multiply each element of this vector by 5 and save this as a new vector named my_var_x5


# 4) Add my_var to my_var_x5 and save this as my_var_final


# 5) Finally, index all values of my_var_final that are greater than 200


# 6) Create a vector of the sequence "1, 2, 3" that repeats itself 5 times.


### Now load the chickenweight data using: data(ChickWeight)
# 7) View the top few observations (rows) in these data:


# 8) How many rows and columns does this dataframe have?


# 9) Extract and define the "Time" column of these data as its own vector two different ways:


# 10) Index the weight of the chicken at the 8th row of data


# 11) Index the weight of the first five and the last five observations and save this as a 
# new vector named my_weights:


# 12) How would we get the last 5 weight values if we didn't know the length of the data
# frame?


# 13) It turns out that weight observations 10, 24, and 132 are faulty data. Replace these values with NAs:


# 14) Calculate the average weight observations in this dataframe and save this as a new variable:


# 15) What is the largest weight recorded in this dataset?


# 16) Create a vector of 20 random integers from 1 through the number of rows in ChickWeight. Then index the 
# ChickWeight data to only those rows and define it as a new dataframe called chick_wt_sub.
# Use the set.seed() function before in order to get the same results I did:


# 17) Let's say we need to transform the chicken weights from grams
# into pounds and all observations with a weight greater than 0.25 lb should be converted to NA.
# Create a custom function that does this transformation to the weight data in our ChickWeight dataframe.
# hint, 1 gram equals about 0.0022 lbs.


# 18) Add a new column in the this dataframe called life_stage, where "early" indicates times less 
# than or equal to 10 and "late" indicates times greater than 10:


# 19) Add a new column that converts time in days (current Time column) to time in hours, and rename
# the columns so that they are all clear, informative, and consistent:


# 20) Finally, order this resulting dataframe by time_hours (earliest times first):


### That's it!


