I am trying to graph the result of multiple runs of a function. The function returns an object that has lists of different lengths.
library(ldbounds)
reas1.lin = bounds(t = c(.5,.75,1),iuse = c(3,3),alpha = c(0.025,0.025))
the result looks like this:
$bounds.type
[1] 2
$spending.type
[1] "Power Family: alpha * t^phi"
$time
[1] 0.50 0.75 1.00
$time2
[1] 0.50 0.75 1.00
$alpha
[1] 0.025 0.025
$overall.alpha
[1] 0.05
$lower.bounds
[1] -2.241403 -2.288491 -2.229551
$upper.bounds
[1] 2.241403 2.288491 2.229551
$exit.pr
[1] 0.0250 0.0375 0.0500
$diff.pr
[1] 0.0250 0.0125 0.0125
attr(,"class")
[1] "bounds"
I would like to get a dataframe that looks like this:
time1 time2 lower.bound upper.bound exit.pr diffpr type
0.50 0.50 -2.241403 2.241403 0.0250 0.0250 Power Family: alpha * t^phi
0.75 0.75 -2.288491 2.288491 0.0375 0.0125 Power Family: alpha * t^phi
1.00 1.00 -2.229551 2.229551 0.0500 0.0125 Power Family: alpha * t^phi
This is how I extracted the data to the above dataframe, but it depends on the number of elements in each list, there must be a more elegant solution to this...
example1.lin <- data.frame(matrix(as.numeric(unlist(reas1.lin)[c(3:8,12:23)]),
nrow=3,
byrow=F),type=reas1.lin$spending.type)