Compactly display the structure of an arbitrary R object

[This article was first published on is.R(), and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

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,
  • Etc.

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.

To leave a comment for the author, please follow the link and comment on their blog: is.R().

R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)