#R Bridge Final Project
r = getOption("repos")
r["CRAN"] = "http://cran.us.r-project.org"
options(repos = r)
install.packages("tidyverse")
## Installing package into 'C:/Users/NCC-1701D/AppData/Local/R/win-library/4.2'
## (as 'lib' is unspecified)
## package 'tidyverse' successfully unpacked and MD5 sums checked
##
## The downloaded binary packages are in
## C:\Users\NCC-1701D\AppData\Local\Temp\RtmpYlqbfP\downloaded_packages
library(readr)
Raw_Data <- read.csv("https://raw.githubusercontent.com/johnnyboy1287/Wages/main/Males.csv")
Raw_Data_DF <- data.frame(Raw_Data)
RemovingNegativeWages <- subset(Raw_Data_DF, wage > 0)
require("knitr")
## Loading required package: knitr
require("ggplot2")
## Loading required package: ggplot2
names(RemovingNegativeWages)[10] <- paste("HourlyWageinDollars")
Ethnicity <- RemovingNegativeWages[1:4360,c(7,10)]
names(Ethnicity)[1] <- paste("Ethnicity")
Marital_Status <- RemovingNegativeWages[1:4360,c(8,10)]
names(Marital_Status)[1] <- paste("Marital Status")
Experience <- RemovingNegativeWages[1:4350,c(5,10)]
names(Experience)[1] <- paste("YearsofExperience")
head(Marital_Status)
## Marital Status HourlyWageinDollars
## 1 no 1.197540
## 2 no 1.853060
## 3 no 1.344462
## 4 no 1.433213
## 5 no 1.568125
## 6 no 1.699891
head(Experience)
## YearsofExperience HourlyWageinDollars
## 1 1 1.197540
## 2 2 1.853060
## 3 3 1.344462
## 4 4 1.433213
## 5 5 1.568125
## 6 6 1.699891
head(Ethnicity)
## Ethnicity HourlyWageinDollars
## 1 other 1.197540
## 2 other 1.853060
## 3 other 1.344462
## 4 other 1.433213
## 5 other 1.568125
## 6 other 1.699891
mean(RemovingNegativeWages$HourlyWageinDollars)
## [1] 1.671902
mean(RemovingNegativeWages[RemovingNegativeWages$ethn == 'black', 'HourlyWageinDollars'])
## [1] 1.557653
mean(RemovingNegativeWages[RemovingNegativeWages$ethn == 'hisp', 'HourlyWageinDollars'])
## [1] 1.638204
mean(RemovingNegativeWages[RemovingNegativeWages$ethn == 'other', 'HourlyWageinDollars'])
## [1] 1.697145
mean(RemovingNegativeWages[RemovingNegativeWages$maried == 'yes', 'HourlyWageinDollars'])
## [1] 1.784073
mean(RemovingNegativeWages[RemovingNegativeWages$maried == 'no', 'HourlyWageinDollars'])
## [1] 1.583309
#boxplot of wages
ggplot(RemovingNegativeWages, aes(x=HourlyWageinDollars)) + geom_boxplot(fill="slateblue", alpha=0.2) + xlab("wages")
#Histogram of Ethnicity
ggplot(Ethnicity, aes(x = Ethnicity)) + geom_bar()
#ScatterPlot of Wages
ggplot(Experience, aes(x=YearsofExperience, y=HourlyWageinDollars)) +
geom_point() + geom_smooth()
## `geom_smooth()` using method = 'gam' and formula 'y ~ s(x, bs = "cs")'
## Warning: Removed 33 rows containing non-finite values (stat_smooth).
## Warning: Removed 33 rows containing missing values (geom_point).