Good Morning, I'm having what I hope to be a simple problem. I am generating bootstrap confidence intervals using package (boot) - which works perfectly. The issue I am having is getting the results into a format which I can write out to a database. To be clear I am having no problems generating the results, I just need to convert the format of the results such that I can store the results in a dataframe to save out to a database. I am doing the following: ## Generate 20,000 bootstrap samples cod.boot <- boot(trimmed$ratio, cod, R=20000) ## generate 90% BCA boostrap confidence intervals codboot <- boot.ci(cod.boot,conf = c(0.90), type= c("bca")) At this point I have stored the answer I want to the variable codboot, but the problem is it is in the format as follows: BOOTSTRAP CONFIDENCE INTERVAL CALCULATIONS Based on 20000 bootstrap replicates CALL : boot.ci(boot.out = cod.boot, conf = c(0.9), type = c("bca")) Intervals : Level BCa 90% ( 6.10, 10.23 ) Calculations and Intervals on Original Scale What I would like is the 6.10, and 10.23 each stored in their own variables so I can combine them into my existing dataframe (using cbind). The best I've been able to do so far is: a <- codboot[c(4)] which gives me a: $bca conf [1,] 0.9 2343.41 19683.87 6.099788 10.23007 which is closer, but I cannot parse this variable enough to get the 6.10 and 10.23 out since apparently strsplit doesn't allow splitting on spaces. Any help would be greatly appreciated! Best Regards & Thank You in Advance Patrick -- Patrick Santoso University of New Hampshire [[alternative HTML version deleted]]
Hi Patrick, How about this (untested)? a <- codboot[c(4)] round(a$bca[4, 5], 2) HTH, Jorge On Thu, May 19, 2011 at 7:20 AM, Patrick Santoso <> wrote:> Good Morning, > > I'm having what I hope to be a simple problem. I am generating bootstrap > confidence intervals using package (boot) - which works perfectly. The > issue > I am having is getting the results into a format which I can write out to a > database. To be clear I am having no problems generating the results, I > just > need to convert the format of the results such that I can store the results > in a dataframe to save out to a database. > > I am doing the following: > > ## Generate 20,000 bootstrap samples > cod.boot <- boot(trimmed$ratio, cod, R=20000) > > ## generate 90% BCA boostrap confidence intervals > codboot <- boot.ci(cod.boot,conf = c(0.90), type= c("bca")) > > At this point I have stored the answer I want to the variable codboot, but > the problem is it is in the format as follows: > > BOOTSTRAP CONFIDENCE INTERVAL CALCULATIONS > Based on 20000 bootstrap replicates > > CALL : > boot.ci(boot.out = cod.boot, conf = c(0.9), type = c("bca")) > > Intervals : > Level BCa > 90% ( 6.10, 10.23 ) > Calculations and Intervals on Original Scale > > What I would like is the 6.10, and 10.23 each stored in their own variables > so I can combine them into my existing dataframe (using cbind). The best > I've been able to do so far is: > > a <- codboot[c(4)] > > which gives me a: > > $bca > conf > [1,] 0.9 2343.41 19683.87 6.099788 10.23007 > > which is closer, but I cannot parse this variable enough to get the 6.10 > and > 10.23 out since apparently strsplit doesn't allow splitting on spaces. > > Any help would be greatly appreciated! > > Best Regards & Thank You in Advance > > Patrick > > > > > > -- > > Patrick Santoso > > University of New Hampshire > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >[[alternative HTML version deleted]]
Hmmm... I am sorry Patrick, it should have been * a <- codboot[c(4)] round(a$bca[4:5], 2) # note I replaced "," by ":" Best, Jorge *> > On Thu, May 19, 2011 at 3:08 PM, Patrick Santoso <> wrote: > >> Thanks for the suggestion Jorge! >> >> - that gives me subscript out of bounds error. perhaps I can tweak the >> parameters? I've never worked with that command. >> >> Pat >> >> On Thu, May 19, 2011 at 2:12 PM, Jorge Ivan Velez <> wrote: >> >>> Hi Patrick, >>> >>> How about this (untested)? >>> >>> a <- codboot[c(4)] >>> round(a$bca[4, 5], 2) >>> >>> HTH, >>> Jorge >>> >>> >>> On Thu, May 19, 2011 at 7:20 AM, Patrick Santoso <> wrote: >>> >>>> Good Morning, >>>> >>>> I'm having what I hope to be a simple problem. I am generating bootstrap >>>> confidence intervals using package (boot) - which works perfectly. The >>>> issue >>>> I am having is getting the results into a format which I can write out >>>> to a >>>> database. To be clear I am having no problems generating the results, I >>>> just >>>> need to convert the format of the results such that I can store the >>>> results >>>> in a dataframe to save out to a database. >>>> >>>> I am doing the following: >>>> >>>> ## Generate 20,000 bootstrap samples >>>> cod.boot <- boot(trimmed$ratio, cod, R=20000) >>>> >>>> ## generate 90% BCA boostrap confidence intervals >>>> codboot <- boot.ci(cod.boot,conf = c(0.90), type= c("bca")) >>>> >>>> At this point I have stored the answer I want to the variable codboot, >>>> but >>>> the problem is it is in the format as follows: >>>> >>>> BOOTSTRAP CONFIDENCE INTERVAL CALCULATIONS >>>> Based on 20000 bootstrap replicates >>>> >>>> CALL : >>>> boot.ci(boot.out = cod.boot, conf = c(0.9), type = c("bca")) >>>> >>>> Intervals : >>>> Level BCa >>>> 90% ( 6.10, 10.23 ) >>>> Calculations and Intervals on Original Scale >>>> >>>> What I would like is the 6.10, and 10.23 each stored in their own >>>> variables >>>> so I can combine them into my existing dataframe (using cbind). The best >>>> I've been able to do so far is: >>>> >>>> a <- codboot[c(4)] >>>> >>>> which gives me a: >>>> >>>> $bca >>>> conf >>>> [1,] 0.9 2343.41 19683.87 6.099788 10.23007 >>>> >>>> which is closer, but I cannot parse this variable enough to get the 6.10 >>>> and >>>> 10.23 out since apparently strsplit doesn't allow splitting on spaces. >>>> >>>> Any help would be greatly appreciated! >>>> >>>> Best Regards & Thank You in Advance >>>> >>>> Patrick >>>> >>>> >>>> >>>> >>>> >>>> -- >>>> >>>> Patrick Santoso >>>> >>>> University of New Hampshire >>>> >>>> [[alternative HTML version deleted]] >>>> >>>> ______________________________________________ >>>> R-help@r-project.org mailing list >>>> https://stat.ethz.ch/mailman/listinfo/r-help >>>> PLEASE do read the posting guide >>>> http://www.R-project.org/posting-guide.html >>>> and provide commented, minimal, self-contained, reproducible code. >>>> >>> >>> >> >> >> -- >> >> Patrick Santoso >> >> 603 969 4673 >> >> >[[alternative HTML version deleted]]