As you advance in your R use past “canned” functions and packages made by others, you may want to take information from one R object for use in another.
For example, you may want to estimate a linear model, then use the results of that estimation to:
- Use coefficient values and the variance-covariance matrix to simulate from the model,
- Visualize model diagnostics, including the distribution of residuals,
- Feed into another model as prior information,
str() is a function that allows you to examine any R object, in order to “see what’s inside,” so to speak. In the case of a linear model produced by lm(), the model object (as well as the model summary object) is a list that contains a lot of information, permitting the assessment of model fit, diagnostic plotting, prediction, etc.
The following Gist is a rather unimaginative introduction to the use of str(), but as is often the case, simply knowing of its existence is of great use.