I'm a fairly experienced R learner right now(for a beginner level), but I am having trouble getting the diamonds dataset as a csv file from the ggplot2 package.
Although I can see it in the environment pane in RStudio for ggplot2 package, I cannot find its file location as a CSV file to import into my working directory.
When in the environment pane, I have tried to Import Dataset, but it doesn't let me select the diamonds dataset from the Data list.
I have also tried finding it's location in the actual Files pane, going into: /cloud/lib/x86_64-pc-linux-gnu-library/4.2, and then into ggplot2, but cannot find the dataset as CSV there anywhere.
Please help with this. I know the answer must be hiding in plane site...
To access the diamonds
dataset, use the below code.
library(ggplot2)
data(diamonds)
Additionally, using write.csv()
will allow you to write a copy of diamonds
to your current working directory.
write.csv(diamonds, "mydata.csv")