Physical Address
304 North Cardinal St.
Dorchester Center, MA 02124
R is a powerful language for data analysis, data visualization, machine learning, statistics. Originally developed for statistical programming, it is now one of the most popular languages in data science. In this course, you’ll be learning about the basics of R, and you’ll end with the confidence to start writing your own R scripts.
But this isn’t your typical textbook introduction to R. You’re not just learning about R fundamentals, you’ll be using R to solve problems related to movies data. Using a concrete example makes the learning painless. You will learn about the fundamentals of R syntax, including assigning variables and doing simple operations with one of R’s most important data structures — vectors!
From vectors, you’ll then learn about lists, matrix, arrays and data frames. Then you’ll jump into conditional statements, functions, classes and debugging. Once you’ve covered the basics – you’ll learn about reading and writing data in R, whether it’s a table format (CSV, Excel) or a text file (.txt). Finally, you’ll end with some important functions for character strings and dates in R.
Module 1 – R Basics
Question: Vectors in R can be which of the following types?
Question: What would be the output in R given: c(1,2) == 1 ?
Question: How would you retrieve the items larger than 5 (as in 15 and 10) from the following vector: costs <- c(3, 15, 3, 10)?
Module 2 – Data structures in R
Question: Give a 5 x 5 matrix object, movies
, how would you retrieve the bottom-left item?
Question: Below we create a list for a student and his info. Select all the correct options can we use to retrieve his courses? john <- list(“studentid“ = 9, “age” = 18, “courses” = c(“Data Science 101”, “Data Science Methodology”))
Question: Select the correct code from the following options which produces the following result?
Module 3 – R programming fundamentals
Question: What output will the following produce?
chance_precipitation <- 0.80
if( chance_precipitation > 0.5 ) {
print("Bring an umbrella") } else {
print("Don't bring an umbrella")}
Question: Which of the following statements are true?
return()
when writing a function is optional when you just want the result of the last line in the function to be the output of the function.return()
when writing a function is necessary even when you just want the result of the last line in the function to be the output of the function.return()
is useful when you want to produce outputs based on different conditions.return()
serves no purpose when you want to produce outputs based on different conditions.Question: Which of the following would you use to check the class of the object, myobject
?
Module 4 – Working with data in R
Question: What does CSV stand for, when talking about tabular data files?
Question: Which of the following are true?
read.csv()
can be used to read in CSV filesdata()
Question: To get the number of characters in a character vector, char_vec
, what function can you use?
Module 5 – Strings and Dates in R
Question: How would you combine the individual words from the vector, hw
, into a single string, “Hello World”?
hw <- c("Hello", "World")
Question: How would you convert the character string “2020-01-01” into a Date object in R?
Question: What does the following regular expression pattern mean?
".*@.+"
Final Exam
Question: Which of the following will return TRUE
?
Question: Which of the following will print out the numbers 1, 2, and 3 only?
Question: How would you get the average of: ratings <- c(8.0, 8.5, 9.0)
Question: How would you convert the following character vector into an integer vector?
my_vector <- c("1992", "2016", "2012", "2018")
Question: If you know an error might occur, what can you do?
tryCatch()
function.Question: You have a file, “november.csv”, in the directory, “/Documents/expenses/“. How do you read this file into R?
Question: You opened a dataset and noticed a row showing Leonardo DiCaprio’s birthday as 153360000. What does it mean?
Question: The following code will produce which of the following outputs?
grep("milk.+", c("cow's milk", "milkshake", "milky", "cat", "milk1", "milk"), value = T)
Question: You want to split a full name, “John Doe”, into a vector containing two elements: “John” and “Doe”. How would you do so?
fullname <- “John Doe”
Question: In R, x <- 1
is the same as x == 1
Question: Look at the code below. How many levels does the factor, drinks
, have?
drinks <- factor(c(“tea”, “coffee”, “soft drink”, “tea”, “hot chocolate”, “hot chocolate”, “coffee”))
Question: To remove an existing column, “firstname”, from a data frame named “people”, which of the following code should you use?
Question: To retrieve the third row of an array named “myarray”, which of the following code should you use?
Question: How would you get the average of the third column of a data frame named “df”?
Question: What is the expected output of the following script?
myfunc <- function(x, y = 2){
x = x + 10
y = y + 100
return(y)
}
myfunc(3)
We hope you know the correct answers to R for Data Science If Queslers helped you to find out the correct answers then make sure to bookmark our site for more Course Quiz Answers.
If the options are not the same then make sure to let us know by leaving it in the comments below.
In our experience, we suggest you enroll in this and gain some new skills from Professionals completely free and we assure you will be worth it.
This course is available on Cognitive Class for free, if you are stuck anywhere between quiz or graded assessment quiz, just visit Queslers to get all Quiz Answers and Coding Solutions.
More Courses Quiz Answers >>
Building Cloud Native and Multicloud Applications Quiz Answers