microbenchmark as data frame or matrix
Asked Answered
E

2

12

is there any way to transform output of function microbenchmark::microbenchmark into the data frame or matrix?

For example

v <- rnorm(100)
m <- microbenchmark(mean(v), sum(v))

The output

Unit: nanoseconds
   expr  min     lq    mean median   uq   max neval
mean(v) 6568 6979.5 9348.19   7390 7390 54600   100
 sum(v)    0    1.0  353.57    411  411  8211   100

I want to use this statistics later so I thought about saving the result as data frame. But as.data.frame(m) doesn't work.

Any help appreciated.

Enalda answered 28/3, 2015 at 23:26 Comment(0)
S
16

This will return a data.frame:

summary(m)
Singlehanded answered 28/3, 2015 at 23:34 Comment(0)
C
3

You can save m as a dataframe with the following code:

m <- summary(microbenchmark(mean(v), sum(v))) #note the addition of summary
m.df<- data.frame(m)
Code answered 28/3, 2015 at 23:28 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.