1. Install package. Display the mean and median for at least two attributes

{require(mt.cars)

print(summary(mtcars))

meanMPG <- mean(mtcars$mpg,na.rm = TRUE)
print(meanMPG)

medianMPG <- median(mtcars$mpg, na.rm = TRUE)
print(medianMPG)

meanCYL <- mean(mtcars$cyl, na.rm = TRUE)
print(meanCYL)

medianCYL <- median(mtcars$cyl, na.rm = TRUE)
print(medianCYL)}

2. Create a new data frame with a subset of the columns and rows. Make sure to rename it.

{newdf <- subset(mtcars, mpg >= 20, select = c(mpg, cyl, disp)}

3. Create new column names for the new data frame.

{colnames(newdf) <- c("a", "b","c")}

4. Use the summary function to create an overview of your new data frame. The print the mean and median for the same two attributes. Please compare.

{summary(newdf)

MPG_mean <- mean(newdf$a, na.rm = TRUE)
print(MPG_mean)

MPG_median <- median(newdf$a, na.rm = TRUE)
print(MPG_median)

CYL_mean <- mean(newdf$b, na.rm = TRUE)
print(MPG_mean)

CYL_median <- median(newdf$b, na.rm = TRUE)
print(CYL_median)} 

5. For at least 3 values in a column please rename so that every value in that column is renamed.

{newdf$a <- as.character(newdf$a) newdf$a[newdf$a == 21.0] <- "fair" newdf$a[newdf$a == 22.8] <- "good" newdf$a[newdf$a == 30.4] <- "excellent"}

6. Display enough rows to see examples of all of steps 1-5 above.

{print(newdf)}

7. BONUS - place the original .csv in a github file and have R read from the link.

{library(RCurl)
gitHubUrl <- getURL("https://raw.githubusercontent.com/vincentarelbundock/Rdatasets/master/csv/datasets/mtcars.csv")
mtCars <- read.csv(text = gitHubUrl)
print(head(mtCars))}