R Programming Quizzes

Recording, Sorting

Question 1

Which R function is specifically designed to save one or more R objects to a file in a native R format (.RData or .rda)?

Question 2

To read data from a comma-separated values file into an R data frame, the most common function to use is _____().

Your answer here.

Question 3

You have a data frame df. Which of the following commands will correctly sort the data frame in descending order based on the score column?

Question 4

What is the primary difference between the sort() and order() functions in R?

Question 5

Which of the following statements about saving and loading data in R are true?

Question 6

The function that saves your entire R workspace to a file (typically .RData) is _____().

Your answer here.

Question 7

How can you sort a data frame students first by grade (ascending) and then by lastName (ascending) for ties within grades?

End of Quiz

Your final score is: 0 / 0

List of Questions

Question 1: Which R function is specifically designed to save one or more R objects to a file in a native R format (.RData or .rda)?

Answers: save().

Question 2: You have a data frame `df`. Which of the following commands will correctly sort the data frame in descending order based on the `score` column?

Answers: df[order(df$score, decreasing = TRUE), ].

Question 3: What is the primary difference between the `sort()` and `order()` functions in R?

Answers: `sort()` returns the sorted values of a vector, while `order()` returns the integer indices needed to produce that sorted order..

Question 4: Which of the following statements about saving and loading data in R are true?

Answers: The `load()` function is used to load R objects from a file created with `save()`., The `save.image()` function is a shortcut for saving all objects in the current workspace., `write.csv(df, file = "data.csv", row.names = FALSE)` will create a CSV file without an extra column for R's row numbers..

Question 5: How can you sort a data frame `students` first by `grade` (ascending) and then by `lastName` (ascending) for ties within grades?

Answers: students[order(students$grade, students$lastName), ].