The “system.time” Function in R

  • Package: Base R (No specific package, it’s a built-in function)

  • Purpose: To measure the execution time of an expression or function.

  • General Class: Profiling/Performance Measurement

  • Required Argument(s):

    • expr: An expression or function call for which the execution time is to be measured.

  • Notable Optional Arguments:

    • None

  • Example:

  • # Example usage
    result <- system.time({
    # Code block to measure execution time
    for (i in 1:1e6) {
    sqrt(i)
    }
    })

    print(result)

  • In this example, system.time is a built-in function in base R, and it is used to measure the execution time of a code block enclosed in curly braces. The expr argument is the expression or function call for which the execution time is to be measured. The result is an object of class proc_time that provides information about the user, system, and elapsed time taken by the execution of the specified expression or function.

Previous
Previous

The “grepl” Function in R

Next
Next

The “grep” Function in R