library()                   # list all available packages
library(lib.loc = .Library) # list all packages in the default library
library(help = splines)     # documentation on package 'splines'
library(splines)            # attach package 'splines'
require(splines)            # the same
search()                    # "splines", too
detach("package:splines")
# if the package name is in a character vector, use
pkg <- "splines"
library(pkg, character.only = TRUE)
detach(pos = match(paste("package", pkg, sep = ":"), search()))
require(pkg, character.only = TRUE)
detach(pos = match(paste("package", pkg, sep = ":"), search()))
require(nonexistent)        # FALSE
## if you want to mask as little as possible, use
library(mypkg, pos = "package:base")
Run the code above in your browser using DataLab