Is there a way to import a package with another name in R, the way you might with import as
in Python, e.g. import numpy as np
? I\'ve been starting
Use the namespace package to generate another namespace aliased to the one you are interested in.
library(namespace)
registerNamespace('ggp', loadNamespace('ggplot2'))
data(iris)
ggp::ggplot(iris, ggp::aes(x = Petal.Length, y = Sepal.Length)) + ggp::geom_point()
Note this has the disadvantage of making the package versioning/installation requirements more opaque for scripts.