Suppose you're asked to write a function in R that takes a data frame and returns a new data frame with only numeric columns. How would you do it?

  • Use the select() function from the dplyr package
  • Use the filter() function from the dplyr package
  • Use the subset() function
  • Use the keep() function from the purrr package
To accomplish this task, you can use the select() function from the dplyr package in R. You can specify the column selection criteria to include only numeric columns and obtain a new data frame with the desired columns.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *