Question: We can also write a for - loop to apply a user - defined function 'checkEvent ( ) ' to each row of a matrix

We can also write a for-loop to apply a user-defined function 'checkEvent()' to each row of a matrix object 'simulatedData' as follows:
val = vector(length = nrow(simulatedData))
for (i in 1:nrow(simulatedData)){
val[i]= checkEvent(simulatedData[i,])
}
Which one of the following is TRUE about this approach?
Question 5 options:
It would be computationally expensive if 'simulatedData' is big.
It will work only if 'simulatedData' has equal number of rows and columns.
It will work only if 'simulatedData' is a matrix of numerical values.
It will take a similar computational time as using the apply() function but the code will be a bit bigger.

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!