It's not a single call, but if you use data(package = "fgeo"), you'll be given info about all the datasets in the fgeo package. If printed, this shows a nicely-formatted page in a new window. But if you assign the output to an object, you can examine it. The results element of that list is a character matrix with all the info you'll need:
data_info <- data(package = "ggplot2")
head(data_info[["results"]])
# Package LibPath Item
# [1,] "ggplot2" "C:/Users/nwerth/Documents/R/win-library/3.4" "diamonds"
# [2,] "ggplot2" "C:/Users/nwerth/Documents/R/win-library/3.4" "economics"
# [3,] "ggplot2" "C:/Users/nwerth/Documents/R/win-library/3.4" "economics_long"
# [4,] "ggplot2" "C:/Users/nwerth/Documents/R/win-library/3.4" "faithfuld"
# [5,] "ggplot2" "C:/Users/nwerth/Documents/R/win-library/3.4" "luv_colours"
# [6,] "ggplot2" "C:/Users/nwerth/Documents/R/win-library/3.4" "midwest"
# Title
# [1,] "Prices of 50,000 round cut diamonds"
# [2,] "US economic time series"
# [3,] "US economic time series"
# [4,] "2d density estimate of Old Faithful data"
# [5,] "'colors()' in Luv space"
# [6,] "Midwest demographics"
You can make a simple wrapper to just get the object names:
get_datasets <- function(package) {
dinfo <- data(package = package)
dinfo[["results"]][, "Item"]
}
get_datasets("ggplot2")
# [1] "diamonds" "economics" "economics_long" "faithfuld"
# [5] "luv_colours" "midwest" "mpg" "msleep"
# [9] "presidential" "seals" "txhousing"