Question: 1 . Copy and paste all the lab questions into your R script and save the R script ( 1 point ) . 2 .

1. Copy and paste all the lab questions into your R script and save the R script (1 point).
2. Comment out all the questions (1 point).
3. Submit the compiled file using the following instructions (1 point):
# Task 1
# copy original dataframe into a new one: my_mtcars
# mtcars object is one of many built-in data sets in R. So you do not need to worry about creating mtcars.
my_mtcars <- mtcars
# 1: investigate my_mtcars using str function. How many variables and observations are included in this dataframe?
# 2: calculate engine displacement per cylinder and save it as a new variable 'UnitEngine' in the dataframe. Populate the two XXXX below
my_mtcars$XXXX <- my_mtcars$XXXX/my_mtcars$cyl
# 3. summarize the new variable 'UnitEngine': use summary function
# ---------------------------------------------------
# Task 2
# 4. create a numeric vector 'Pets' with this numbers (1,1,1,0,0)
# 5. create a numeric vector 'Order' with these numbers (3,1,2,3,3)
# create a numeric vector 'Siblings'
Siblings <- c(0,3,5,0,0)
# create a numeric vector 'IDs'
IDs <- c(1,2,3,4,5)
# 6. Combine those four numeric vectors together into a dataframe called 'myFriends'. You must use data.frame function
# 7. report the structure of the dataframe
# 8. summarize the dataframe. Use summary function
# list (or print) all of the values for 'IDs' variable in the dataframe
myFriends$IDs
# list all of the values for 'Pets' variable in the dataframe
# 9. list all of the values for 'Order' variable in the dataframe
# list all of the values for 'Siblings' variable in the dataframe
myFriends$Siblings
# # 10. write a code to print the values in the fifth observation of the Pets variable
## 11. add a vector called 'age' to 'myFriends' using cbind function. *** YOU MUST USE cbind FUNCTION to receive full grades.
age <-c(23,21,45,21,18)
## 12. define a vector called 'names' by including all the names in a vector. Add a vector 'names' to 'myFriends' using cbind function. Print the structure of 'myFriends'. What is NOT the data type (among: factor, numeric, logical, string) of the 'names'?
names <-c("John", "Smith", "Susan", "Joe", "Wendy")

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!