#Inputting wage data df <- read.csv("wage.csv", header = TRUE) #Giving our variables shorter names wage <- df$WAGE ed <- df$ED hsd <- df$HSDROP hsg <- df$HSGRAD assc <- df$ASSOC bach <- df$BACH age <- df$AGE fmale <- df$FEMALE nonwh <- df$NONWH hisp <- df$HISP #Getting summary statistics for different variables summary(df) summary(wage) summary(df$WAGE) #Plotting different variables by wage plot(df$ED,df$WAGE) plot(ed,wage, col = "blue", pch = 4) plot(fmale,wage) plot(age,wage) #Plotting wage vs age by sex plot(age,wage,pch=c(2,8)[unclass(df$SEX)],col=c("red","blue")[unclass(df$SEX)]) legend("topleft",legend = c("Female", "Male"), col = c("red","blue"), pch = c(2,8)) #Plotting wage vs age by educational attainment plot(age,wage,pch=c(2,8,1,3)[unclass(df$EDSTR)],col=c("orange", "purple", "black","blue")[unclass(df$EDSTR)]) legend("topleft",legend = c("hsd", "hsg", "assoc", "bach"), col = c("black", "blue","orange", "purple"), pch = c(1,3,2,8)) #Clearing out our environment remove(list = ls()) #Clearing all plots dev.off(dev.list()["RStudioGD"]) #Clearing the console cat("\014") #Gather another data set to play with #Inputting the data from Google Trends, and naming the variables trends <- read.csv("multiTimeline.csv",header=T) batman <- trends$Batman superman <- trends$Superman wonderwoman <- trends$WonderWoman #Plotting the variables together on one plot plot(batman,type='l',col="black") lines(superman,col="blue") lines(wonderwoman,col="darkgoldenrod") #Adjusting the axis and recreating the plot plot(batman,type='l',col="black", ylim = c(0,100)) lines(superman,col="blue") lines(wonderwoman,col="darkgoldenrod") #Plotting the densities of each variable together - need to plot Superman first, since it has a higher mode plot(density(wonderwoman),col="darkgoldenrod",xlim=c(0,100), main = "Superhero Densities") lines(density(superman), col="blue") lines(density(batman)) #Use the par command to put 4 plots together on one page par(mfrow=c(1,2)) plot(batman,type='l',col="black", ylim = c(0,100), main = "Superhero Scores", ylab = "Trend Score") lines(superman,col="blue") lines(wonderwoman,col="darkgoldenrod") plot(density(wonderwoman),col="darkgoldenrod",xlim=c(0,100), main = "Superhero Densities", xlab = "Trend Score") lines(density(superman), col="blue") lines(density(batman))