Error in library

I am trying to look at the diamonds data. I used the code below. And I keep getting the message below:

diamonds

Error in library(diamonds) : there is no package called ‘diamonds’

What am I doing wrong?

Can you please list out your packages? Diamonds data does come with one of them.

Diamonds dataset is part of ggplot2 package. Have you installed and loaded ggplot2?

1 Like

@hinkelman is right. The dataset is included in the package.

it is a pretty common case to have data included in :package:. It helps for example or for provide dataset to others.

You can see the dataset available in your installed :package: by calling

data()

it will open a panel listing all the available datasets andin which package.

To load a dataset you see, you can call data(<name of the dataset>). For diamonds, you need to have ggplot2 installed, then you can call it

data("diamonds") # or data("diamonds", package = "ggplot2")
names(diamonds)
#>  [1] "carat"   "cut"     "color"   "clarity" "depth"   "table"   "price"  
#>  [8] "x"       "y"       "z"

Created on 2018-11-02 by the reprex package (v0.2.1)

@jrazak, if you really talk about the diamonds dataset, please rename your title question accordingly. thanks.

2 Likes