For this lab, let’s explore the mtcars dataset that is included within R.

As we are about halfway through the course, this activity description does not provide the same level of code prompts as previous labs – it is assumed that you remember or can lookup the necessary code. The overall goal of this activity is to use the package called ggplot2 to show different attributes of the mtcars data set. More information about making visualizations using ggplot() can be found here: ggplot().

Please be sure to first install ggplot2 using install.packages("ggplot2") and include both the code and the images that were generated with your assignment.

Please generate the following visualizations:

Note: A common issue with base R datasets is record names are included as index values and not columns in the dataframe. Run this code to place car names in a column and add numeric values to the index

This code takes the rownames from mtcars and column binds cbind() the names and the dataset
mtcars <- cbind(car = rownames(mtcars), mtcars)
This code creates new rownames and places then in the index of mtcars  
rownames(mtcars) <- 1:nrow(mtcars)

If you finish early do some research about the melt() function in R.

LS0tCnRpdGxlOiAiTGFiIDY6IERhdGEgVmlzdWFsaXphdGlvbiIKYXV0aG9yOiAKLSBbWU9VUiBOQU1FXQotIFtZT1VSIFBBUlRORVJTIE5BTUVdCmRhdGU6ICJgciBTeXMudGltZSgpYCIKb3V0cHV0OiBodG1sX25vdGVib29rCi0tLQpGb3IgdGhpcyBsYWIsIGxldOKAmXMgZXhwbG9yZSB0aGUgYGBgbXRjYXJzYGBgIGRhdGFzZXQgdGhhdCBpcyBpbmNsdWRlZCB3aXRoaW4gUi4gCgpBcyB3ZSBhcmUgYWJvdXQgaGFsZndheSB0aHJvdWdoIHRoZSBjb3Vyc2UsIHRoaXMgYWN0aXZpdHkgZGVzY3JpcHRpb24gZG9lcyBub3QgcHJvdmlkZSB0aGUgc2FtZSBsZXZlbCBvZiBjb2RlIHByb21wdHMgYXMgcHJldmlvdXMgbGFicyDigJMgaXQgaXMgYXNzdW1lZCB0aGF0IHlvdSByZW1lbWJlciBvciBjYW4gbG9va3VwIHRoZSBuZWNlc3NhcnkgY29kZS4gVGhlIG92ZXJhbGwgZ29hbCBvZiB0aGlzIGFjdGl2aXR5IGlzIHRvIHVzZSB0aGUgcGFja2FnZSBjYWxsZWQgYGBgZ2dwbG90MmBgYCB0byBzaG93IGRpZmZ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