Displaying R Package Information in a Human-Readable Format

The code provided is a R script that displays information about the packages installed in the current R session.

To answer your question, there isn’t a specific line of code to convert the output of the package info function into a human-readable format. However, you can use the print() or cat() functions to display the results in a more readable way.

Here is an example:

# Package information
pkg <- pkginfo()
print(pkg)

This will display all the packages that are currently installed and loaded in the R environment.

If you want to format it differently, for example, with headings and alignment, you might use something like this:

# Package information

# List of packages
for (i in 1:nrow(pkg)) {
  cat("Package:", pkg$Package[i], "\n")
  cat("Version:", pkg$Version[i], "\n\n")
}

This will display each package on a separate line, followed by its version.


Last modified on 2025-04-06