rgraphicsfitdistrplus

How do I obtain values from a graphic?


I did a distribution fit and was taking a look at the Q-Q-Plot and was wondering if there is an easy way to get the corresponding values from the graphic.

library("fitdistrplus")
data <- c(1050000, 1100000, 1230000, 1300000, 1450000, 1459785, 1654000, 1888000)
lognormalfit <- fitdist(data, "lnorm")
qqcomp(lognormalfit)

With the last line of code I receive the Q-Q-Plot without calculating the values. But I am also interested in the values. How can I obtain them?

Best regards Norbi


Solution

  • qqcomp has an option to produce the plot using ggplot2: this type of plot returns an object with the data. So you can grab the plot and data with

    plotData <- qqcomp(lognormalfit, plotstyle = "ggplot") 
    

    and then you can grab the relevant data from the plot object using

    plotData$data
    #   values   ind   sdata
    #1 1026674 lnorm 1050000
    #2 1158492 lnorm 1100000
    #3 1247944 lnorm 1230000
    #4 1327616 lnorm 1300000
    #5 1407939 lnorm 1450000
    #6 1497825 lnorm 1459785
    #7 1613479 lnorm 1654000
    #8 1820639 lnorm 1888000