Skip to Content
RStudio for R Statistical Computing Cookbook
book

RStudio for R Statistical Computing Cookbook

by Andrea Cirillo
April 2016
Beginner to intermediate content levelBeginner to intermediate
246 pages
5h 20m
English
Packt Publishing
Content preview from RStudio for R Statistical Computing Cookbook

Comparing an alternative function's performance using the microbenchmarking package

When dealing with efficiency issues, a fast way to evaluate two alternative functions can be really useful.

This recipe is going to show you how to do this quickly and effectively and display the results of your comparison in a ggplot diagram that is easy to understand.

Getting ready

This recipe is going to leverage the microbenchmark package to compute the function comparison and the ggplot2 package for comparison plotting:

install.packages(c("microbenchmark","ggplot2"))
library(microbenchmark)
library(ggplot2)

The example that follows is represented by two alternative functions to determine, for a given numeric vector, which elements of the vector are even and which ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Practical Data Analysis Using Jupyter Notebook

Practical Data Analysis Using Jupyter Notebook

Marc Wintjen

Publisher Resources

ISBN: 9781784391034Supplemental Content