introduction to r programming for data science coursera answers week 5

Final Exam

1. Which of the following is a typical way that developers use the R language?

  • Transaction processing
  • Mobile app development
  • Data visualization
  • Web page interactivity

2. In R, what is the result of the function as.character(10.3)?

  • True
  • “10.3”
  • NA
  • 10

3. One movie is 150 minutes long, and another is 90 minutes long. Using R, which of the following commands would correctly calculate the difference in length, in seconds, between the two films?

  • (150-90\*60)
  • 150-90\*60
  • (150-90)\*60
  • 150-(90\*60)

 

4. Which command in R would return the following numeric vector? 5 4 3 2 1

  • c(1:5)
  • c(5-\>1)
  • c(1, 2, 3, 4, 5)
  • c(5:1)

5. In R, assume you have a vector named “age,” and each element in the vector is the age of one person in a group. The vector has the following content: 24 32 46 19. What will be the result if you issue the age[-2] command?

  • 2 3 4 1
  • 224 232 246 219
  • 24 46 19
  • 22 30 44 17

6. Assume the array books_array contains 6 elements. The array has three rows and two columns and appears as follows:

[,1] [,2] [1,] "It" "Dr. Sleep" [2,] "Misery" "Carrie" [3,] "The Shining" "The Mist"

If you input the books_array[,1] command, what will be the output?

  • “The Shining”
  • “It” “Misery” “The Shining”
  • “It” “Dr. Sleep”
  • “It”

7. In R, which command should you use to insert a new row into a data frame?

  • head
  • rbind
  • integrate
  • tail

8. Which of the following blocks of R code properly defines a function that takes two numbers as input and returns the product of the two numbers multiplied together?

  • mult \<- function {x\*y}
  • mult \<- function() {x\*y}
  • mult \<- function(xy) {x\*y}
  • mult \<- function(x, y) {x\*y}

9. In R, which command will read the file books-db.csv?

  • read.csv (books-db.csv)
  • read.books-db.csv
  • books-db.csv
  • return books-db.csv

10. After installing and calling the httr library in R, which method should you use to send data to a server to create a resource?

  • POST
  • BROWSE
  • PATCH
  • GET

Leave a Reply