12.1 Example: Packages

# Create a matrix
M <- diag(5)
M[1:20]<- c(1:20)
M

ginv(M)  # Funkcion ginv()
# ginv calculates the Moore-Penrose-Inverse of the matrix M
# But it doesn not work here.. why?

help.search("ginv") # function is in the package MASS

install.packages("MASS") # Install package
MASS::ginv(M) # Call function without loading the whole package

library(MASS) # Load whole package
ginv(M)

ls("package:MASS") # Display content of the package MASS

detach("package:MASS") # Unload the package
ginv(M)
search()

library()
remove.packages("MASS")
library() # Package is not installed anymore