Press "Enter" to skip to content

One Line to Get and Print All Loaded Library Packages in R

This function is really only useful for those of us who try to rapidly develop a script to give our output, whether it is a plot in ggplot, CSV file, or an html widget. Today I was working on a script which utilized the leaflet R package among some other libraries which was slowly devolving into something less maintainable than I prefer.

Anyhow, if you ever get to the point where you want to retroactively add the library calls to the beginning of your script based on what you have currently loaded, this is for you.

It is a simple one-liner which has made my life a little easier. Broken down you get

Which outputs EVERYTHING. You might want to trim it down farther.

Hope this helps some others!

Sharing is caring!

Be First to Comment

    Leave a Reply

    Your email address will not be published. Required fields are marked *