Introduction to R Programming for Data Science | week 4

Course Link: Introduction to R Programming for Data Science | Coursera

Practice Quiz

1. Which package do you need to install before reading an Excel file in R?

readxlsx

No package is needed. This functionality is built into R.

readxl

readExcel

2. What is the purpose of the readLines() function?

Reads each text line (with a line break) in a text file and returns a character variable.

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

Reads each text line (ending with a line break) in a text file and returns a character factor.

Reads each text line (with a line break) in a text file and returns a data frame.

3. Which data structure is more suitable to be exported into a text file rather than a .csv or Excel file?

String or characters

Matrices

Data frames

Datasets

4. Complete the sentence: _________________ is a communication protocol for fetching web resources for clients from servers on the Internet.

HTTP

REST

TCP

DNS

5. 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.

Sibling nodes

Root nodes

Nested nodes

Child nodes

Graded Quiz

1. 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?

employee[5, c(“name”, “title”)]

employee[c(“name”, “title”), 5]

employee[2:3, 1:5]

employee[5, 2:3]

2. How do you return the number of characters in each paragraph of a text file that has been read into a character vector?

Use the scan() function.

Use the file.size() function.

Use the nchar() function.

Use the length() function.

3. Which package do you need to install before writing to an Excel file in R?

No package is needed. This functionality is built into R.

writexl

writexlsx

xlsx

4. 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?

response <-HEAD(“https://www.mysite.com”)

response <-POST(“https://www.mysite.com”)

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

response <-PUT(“https://www.mysite.com”)

5. aAfter reading an HTML page from a URL, what must you do to get the <body> node from the root <html> node?

Use the html_text() function to return the <body> node of the HTML.

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

Use the html_text() function to return the <html> node.

Use the html_node() function to return the <html> node.

* The material and content uploaded on this website are for general information and reference purposes only and don’t copy the answers of this website to any other domain without any permission or else copyright abuse will be in action.

Please do it by your own first!

DMCA.com Protection Status


More From Kuizzer

Introduction to R Programming for Data Science | week 1

Introduction to R Programming for Data Science | week 2

Introduction to R Programming for Data Science | week 3

Introduction to R Programming for Data Science | week 4

Introduction to R Programming for Data Science | week 5

0 0 votes
Article Rating
Subscribe
Notify of
guest

2 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments



2
0
Would love your thoughts, please comment.x
()
x