J.Zhang J.Zhang - 1 month ago 10
R Question

How can I read the specified column in the generated data frame in R?

Here is my code:

x<-c(1300,541,441,35,278,167,276,159,126,60.8,160,5000,718,9740,135,3480,264.6,379,170,251.3,155.84,187.01,850)
y<-log10(x)
# load fitdistrplus package for using fitdist function
library(fitdistrplus)
# fit logistic distribution using MLE method
x.logis <- fitdist(y, "logis", method="mle")
b1 <- bootdist(x.logis, bootmethod="param", niter=20)
b1# Here are 20 b1.


How can i read the parameter values (location) in b1 ? Thank you very much !

Answer

Use the str function to inspect the structure of the data. In fact, b1 is a list, and the first object of this list contain a regular data frame.

# extract the data frame for the first object of the list
data <- b1$estim
data$location
data$scale
# Also you can use the double bracket operator
b1[[1]][, "location"]

In the last part of the code you can notice that the double square brackets are used for subset the object of the list, and the normal square brackets are for subset the elements of the object.

Comments