nerdexam
Dell-EMC

E20-007 · Question #127

A data scientist is given an R data frame, "empdata", with the columns Age, Salary, Occupation, Education, and Gender. The data scientist would like to examine only the Salary and Occupation columns…

The correct answer is A. empdata[empdata$Age > 40,c("Salary","Occupation")]. See the full explanation below for the reasoning.

Question

A data scientist is given an R data frame, "empdata", with the columns Age, Salary, Occupation, Education, and Gender. The data scientist would like to examine only the Salary and Occupation columns for ages greater than 40. Which command extracts the appropriate rows and columns from the data frame?

Options

  • Aempdata[empdata$Age > 40,c("Salary","Occupation")]
  • Bempdata[c("Salary","Occupation"),empdata$Age > 40]
  • Cempdata[Age > 40,("Salary","Occupation")]
  • Dempdata[,c("Salary","Occupation")]$Age > 40

How the community answered

(64 responses)
  • A
    72% (46)
  • B
    16% (10)
  • C
    8% (5)
  • D
    5% (3)

Community Discussion

No community discussion yet for this question.

Full E20-007 Practice