# [R] Result show the values of fitting gamma parameter

Mon Jan 29 12:36:23 CET 2018

```Hello,

I believe the following is simpler.
It changes the OP's code a bit and uses lapply, not apply.

res2 <- lapply(C, fitdist, "gamma")
do.call(rbind, lapply(res2, `[[`, "estimate"))
#      shape     rate
#A  3.702253 1.234126
#B 31.300800 3.912649

Hope this helps,

On 1/29/2018 10:25 AM, Eric Berger wrote:
> Capture the results of the apply command into an object and then work with
> that. Here is one way to do it:
>
>> res <- apply(C, 2, fitdist, "gamma")
>> out <- c( res\$A\$estimate["shape"], res\$B\$estimate["shape"],
> res\$A\$estimate["rate"], res\$B\$estimate["rate"])
>> names(out) <- c("A shape","B shape","A rate","B Rate")
>> print(out)
>
> #   A shape   B shape    A rate    B Rate
> # 3.702253 31.300800  1.234126  3.912649
>
> HTH,
> Eric
>
>
> On Mon, Jan 29, 2018 at 10:25 AM, smart hendsome via R-help <
> r-help at r-project.org> wrote:
>
>> Hi,
>> Let say I have data by two columns A and B, and I have fit each column
>> using the gamma distribution by 'fitdist' . I just want the result show
>> only the shape and rate only.
>>
>> Eg:
>> library(fitdistrplus)
>>
>> A <-c(1,2,3,4,5)
>>
>> B<-c(6,7,8,9,10)
>>
>> C <-cbind(A,B)
>> apply(C, 2, fitdist, "gamma")
>> Output show like this:
>> \$A
>> Fitting of the distribution ' gamma ' by maximum likelihood
>> Parameters:
>>        estimate Std. Error
>> shape 3.702253  2.2440052
>> rate  1.234126  0.8011369
>>
>> \$B
>> Fitting of the distribution ' gamma ' by maximum likelihood
>> Parameters:
>>         estimate Std. Error
>> shape 31.300800   19.69176
>> rate   3.912649    2.48129
>>
>> I want the output to be like this:
>>                   A                    B
>>   shape 3.702253  31.300800rate  1.234126  3.912649
>> Can anyone solve my problem? Many thanks.
>>
>> Regards,
>> Zuhri
>>
>>
>>
>>
>>          [[alternative HTML version deleted]]
>>
>> ______________________________________________
>> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>
> 	[[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help