Introduction to R Programming for Data Science Week 4 Answers

Course Name: Introduction to R Programming for Data Science

Course Link: Click Here

These are answers of Introduction to R Programming for Data Science Week 4


Practice Quiz

Q1. Which package do you need to install before reading an Excel file in R?
a. readExcel
b. readxl
c. readxlsx
d. No package is needed. This functionality is built into R.

Answer: b. readxl


Q2. What is the purpose of the readLines() function?
a. Reads each text line (ending with a line break) in a text file and returns a character factor.
b. Reads each text line (with a line break) in a text file and returns a data frame.
c. Reads each text line (with a line break) in a text file and returns a character variable.
d. Reads each text line (ending with a line break) in a text file and returns a character vector.

Answer: d. Reads each text line (ending with a line break) in a text file and returns a character vector.


These are answers of Introduction to R Programming for Data Science Week 4


Q3. Which data structure is more suitable to be exported into a text file rather than a .csv or Excel file?
a. String or characters
b. Matrices
c. Data frames
d. Datasets

Answer: a. String or characters


Q4. Complete the sentence: _________________ is a communication protocol for fetching web resources for clients from servers on the Internet.
a. HTTP
b. REST
c. TCP
d. DNS

Answer: a. HTTP


These are answers of Introduction to R Programming for Data Science Week 4


Q5. Complete the sentence: In an HTML page, if the <head> and <body> nodes have the same parent, <html>, they are said to be ___________________ to each other.
a. Nested nodes
b. Sibling nodes
c. Child nodes
d. Root nodes

See also  Introduction to R Programming for Data Science Week 5 Final Answers

Answer: b. Sibling nodes


These are answers of Introduction to R Programming for Data Science Week 4


Graded Quiz

Q1. Assume you have read a .csv file into a data frame variable called employee. It has 20 rows of data and three variables: name, age, and title. What is the correct statement to use to return the fifth row of data in the name and title columns?
a. employee[2:3, 1:5]
b. employee[c(“name”, “title”), 5]
c. employee[5, 2:3]
d. employee[5, c(“name”, “title”)]

Answer: d. employee[5, c(“name”, “title”)]


Q2. How do you return the number of characters in each paragraph of a text file that has been read into a character vector?
a. Use the nchar() function.
b. Use the length() function.
c. Use the scan() function.
d. Use the file.size() function.

Answer: a. Use the nchar() function.


These are answers of Introduction to R Programming for Data Science Week 4


Q3. Which package do you need to install before writing to an Excel file in R?
a. writexl
b. writexlsx
c. No package is needed. This functionality is built into R.
d. xlsx

Answer: d. xlsx


Q4. You want to get a resource by its URL using an HTTP request and assign the HTTP response containing status code, headers, response body to a response variable. Which function should you use?
a. response <-HEAD(“https://www.mysite.com”)
b. response <- GET(“https://www.mysite.com”)
c. response <-POST(“https://www.mysite.com”)
d. response <-PUT(“https://www.mysite.com”)

Answer: b. response <- GET(“https://www.mysite.com”)


These are answers of Introduction to R Programming for Data Science Week 4


Q5. After reading an HTML page from a URL, what must you do to get the <body> node from the root <html> node?
a. Use the html_text() function to return the <html> node.
b. Use the html_node() function to return the <html> node.
c. Use the html_text() function to return the <body> node of the HTML.
d. Use the html_node() function to return the <body> as a child node of <html> node.

See also  Introduction to R Programming for Data Science Week 1 Answers

Answer: d. Use the html_node() function to return the <body> as a child node of <html> node.


These are answers of Introduction to R Programming for Data Science Week 4



All weeks answers of Introduction to R Programming for Data Science: Click Here

These are answers of Introduction to R Programming for Data Science Week 4


These are answers of Introduction to R Programming for Data Science Week 4