Suppose you're given a data frame in R and asked to find the maximum or minimum value in each column or row. How would you do this?

  • Use the apply() function with the appropriate margin argument and the max() or min() function
  • Use the max.col() or min.col() function for data frames
  • Use the apply() function with the appropriate margin argument and the max_row() or min_row() function
  • Use the max() or min() function with the appropriate argument and the apply() function
To find the maximum or minimum value in each column or row of a data frame in R, you can use the apply() function with the appropriate margin argument (1 for rows, 2 for columns) and the max() or min() function. This combination allows you to apply the max() or min() function across the specified dimension and obtain the desired results.
Add your answer
Loading...

Leave a comment

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