Question: Read a data set in R as a data frame. How to write a function that takes as arguments: 1) a data frame, 2) a

Read a data set in R as a data frame.

How to write a function that takes as arguments: 1) a data frame, 2) a column number

for that data frame, and outputs: 1) the maximum value of that column ; 2) the row

index (or patient) corresponding to that maximum value; 3) the minimum value of

that column; 4) its corresponding row index.

The answer should following the way like this:

Read a data set in R as a data frame. How to

> max . calc for (j in 3:8) print (max.calc(dat,j)) max.val max.ind min.val min.ind 114 121 119 118 max.val max.ind min.val min.ind 7 max.val max.ind min.val min.ind 7 27 100 max.val max.ind min.val min.ind 8 27 102 max.val max.ind min.val min.ind 10 115 24 97 max.val max.ind min.val min.ind 24 63 18 38 > max . calc for (j in 3:8) print (max.calc(dat,j)) max.val max.ind min.val min.ind 114 121 119 118 max.val max.ind min.val min.ind 7 max.val max.ind min.val min.ind 7 27 100 max.val max.ind min.val min.ind 8 27 102 max.val max.ind min.val min.ind 10 115 24 97 max.val max.ind min.val min.ind 24 63 18 38

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!