For this project, I used the H1B Visa data set - I tidied the data to specidically looks at H1B Visa Petitions for each country and year
Load Libraries and read csv file
library(tidyr)
library(dplyr)
##
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
library(ggplot2)
library(knitr)
data <- read.csv('/Users/christinakasman/Desktop/H1B Data.csv', header=FALSE, sep=",", stringsAsFactors=FALSE)
my.new.data <- data[-c(2), ]
my.new.data <- data[-c(3, 5, 16, 12, 17, 42, 43, 47, 48, 57, 58, 62, 63, 76, 80, 81), ]
newdata <- as.data.frame(t(my.new.data))
Create Table for Countries - Change header to be first row of dataframe
Countries <- newdata[c(1:12) ,c(13:33, 35)]
as.data.frame(Countries)
## 18 19 20 21 22 23
## V1 India China, People's Republic of Philippines South Korea Canada
## V2 2007 166575 26370 12230 10730 8562
## V3 2008 157608 24434 10713 10277 7111
## V4 2009 122475 22411 10407 10704 7871
## V5 2010 135931 21119 8887 8721 7342
## V6 2011 155791 23227 9098 7480 6761
## V7 2012 197940 22528 9400 7204 6688
## V8 2013 201114 23924 7399 5576 5478
## V9 2014 227172 27733 6772 4897 5267
## V10 2015 269677 32485 4147 4298 5050
## V11 2016 300902 35720 3704 4269 4547
## V12 2017 247927 36362 3161 3203 3551
## 24 25 26 27 28 29 30 31 32
## V1 Taiwan Mexico United Kingdom Pakistan France Brazil Nepal Japan Turkey
## V2 5394 4259 5105 4259 4112 3056 2775 2913 2415
## V3 4088 3680 4241 3803 3687 2498 2538 2374 2028
## V4 4308 3599 4270 3683 3035 2495 2724 2253 2041
## V5 4325 3260 3651 3012 2660 2595 2467 2225 2023
## V6 4511 3439 3241 3033 2531 2644 2169 2172 2020
## V7 4172 3602 3130 2765 2292 2557 2066 2030 1966
## V8 3520 2985 2330 2381 2192 2346 1788 1755 1658
## V9 3267 2769 1988 2497 2024 2353 1598 1664 1665
## V10 2555 2462 1697 2512 2048 2111 1512 1553 1711
## V11 2287 2315 1528 2401 1998 1992 1504 1481 1709
## V12 2200 2239 1783 1536 1474 1517 1249 1077 1177
## 33 34 35 36 37 38 40
## V1 Germany Iran Italy Russia Venezuela Spain All Other
## V2 3168 2531 1353 2446 1262 1079 44027
## V3 2482 1930 1533 1760 1159 974 36557
## V4 2182 1952 1437 1544 1302 933 34500
## V5 1875 1897 1361 1434 1299 1018 31170
## V6 1737 1755 1613 1570 1398 1233 30989
## V7 1650 1676 1922 1499 1540 1140 30475
## V8 1319 1362 1722 1318 1370 1230 26923
## V9 1256 1331 1865 1323 1339 1201 25990
## V10 1164 1230 1894 1275 1247 1110 27114
## V11 1006 1152 1639 1154 1208 1094 25739
## V12 1127 1332 918 948 873 861 21592
colnames(Countries) = as.character(unlist(Countries[1,])) # the first row will be the header
Countries1 = Countries[-1, ]
colnames(Countries1)[1] <- "Year"
Countries2 <- gather(Countries1, "Country", "H1B_Petitions_Filed", 2:22)
## Warning: attributes are not identical across measure variables;
## they will be dropped
Group by Country and summarise
#Have to change to .numeric for correct character type
Countries3 <- Countries2 %>% group_by(Country) %>%
summarise(Total_H1B_Petitions_Filed = sum(as.numeric(H1B_Petitions_Filed)))
Countries3 <- arrange(Countries3, desc(as.numeric(Total_H1B_Petitions_Filed)))
Total H1B Visas from 2007-2017 per Country. India had the highest number of H1B Visa petitions, by more than 7 times any other country Why does india have the most: https://www.recode.net/2017/4/13/15281170/china-india-tech-h1b-visas
kable(Countries3)
| Country | Total_H1B_Petitions_Filed |
|---|---|
| India | 2183112 |
| All Other | 335076 |
| China, People’s Republic of | 296313 |
| Philippines | 85918 |
| South Korea | 77359 |
| Canada | 68228 |
| Taiwan | 40627 |
| Mexico | 34609 |
| United Kingdom | 32964 |
| Pakistan | 31882 |
| France | 28053 |
| Brazil | 26164 |
| Nepal | 22390 |
| Japan | 21497 |
| Turkey | 20413 |
| Germany | 18966 |
| Iran | 18148 |
| Italy | 17257 |
| Russia | 16271 |
| Venezuela | 13997 |
| Spain | 11873 |
Countriesyear <- Countries2 %>% group_by(Country, Year) %>%
summarise(totalyear = sum(as.numeric(H1B_Petitions_Filed)))
kable(Countriesyear)
| Country | Year | totalyear |
|---|---|---|
| All Other | 2007 | 44027 |
| All Other | 2008 | 36557 |
| All Other | 2009 | 34500 |
| All Other | 2010 | 31170 |
| All Other | 2011 | 30989 |
| All Other | 2012 | 30475 |
| All Other | 2013 | 26923 |
| All Other | 2014 | 25990 |
| All Other | 2015 | 27114 |
| All Other | 2016 | 25739 |
| All Other | 2017 | 21592 |
| Brazil | 2007 | 3056 |
| Brazil | 2008 | 2498 |
| Brazil | 2009 | 2495 |
| Brazil | 2010 | 2595 |
| Brazil | 2011 | 2644 |
| Brazil | 2012 | 2557 |
| Brazil | 2013 | 2346 |
| Brazil | 2014 | 2353 |
| Brazil | 2015 | 2111 |
| Brazil | 2016 | 1992 |
| Brazil | 2017 | 1517 |
| Canada | 2007 | 8562 |
| Canada | 2008 | 7111 |
| Canada | 2009 | 7871 |
| Canada | 2010 | 7342 |
| Canada | 2011 | 6761 |
| Canada | 2012 | 6688 |
| Canada | 2013 | 5478 |
| Canada | 2014 | 5267 |
| Canada | 2015 | 5050 |
| Canada | 2016 | 4547 |
| Canada | 2017 | 3551 |
| China, People’s Republic of | 2007 | 26370 |
| China, People’s Republic of | 2008 | 24434 |
| China, People’s Republic of | 2009 | 22411 |
| China, People’s Republic of | 2010 | 21119 |
| China, People’s Republic of | 2011 | 23227 |
| China, People’s Republic of | 2012 | 22528 |
| China, People’s Republic of | 2013 | 23924 |
| China, People’s Republic of | 2014 | 27733 |
| China, People’s Republic of | 2015 | 32485 |
| China, People’s Republic of | 2016 | 35720 |
| China, People’s Republic of | 2017 | 36362 |
| France | 2007 | 4112 |
| France | 2008 | 3687 |
| France | 2009 | 3035 |
| France | 2010 | 2660 |
| France | 2011 | 2531 |
| France | 2012 | 2292 |
| France | 2013 | 2192 |
| France | 2014 | 2024 |
| France | 2015 | 2048 |
| France | 2016 | 1998 |
| France | 2017 | 1474 |
| Germany | 2007 | 3168 |
| Germany | 2008 | 2482 |
| Germany | 2009 | 2182 |
| Germany | 2010 | 1875 |
| Germany | 2011 | 1737 |
| Germany | 2012 | 1650 |
| Germany | 2013 | 1319 |
| Germany | 2014 | 1256 |
| Germany | 2015 | 1164 |
| Germany | 2016 | 1006 |
| Germany | 2017 | 1127 |
| India | 2007 | 166575 |
| India | 2008 | 157608 |
| India | 2009 | 122475 |
| India | 2010 | 135931 |
| India | 2011 | 155791 |
| India | 2012 | 197940 |
| India | 2013 | 201114 |
| India | 2014 | 227172 |
| India | 2015 | 269677 |
| India | 2016 | 300902 |
| India | 2017 | 247927 |
| Iran | 2007 | 2531 |
| Iran | 2008 | 1930 |
| Iran | 2009 | 1952 |
| Iran | 2010 | 1897 |
| Iran | 2011 | 1755 |
| Iran | 2012 | 1676 |
| Iran | 2013 | 1362 |
| Iran | 2014 | 1331 |
| Iran | 2015 | 1230 |
| Iran | 2016 | 1152 |
| Iran | 2017 | 1332 |
| Italy | 2007 | 1353 |
| Italy | 2008 | 1533 |
| Italy | 2009 | 1437 |
| Italy | 2010 | 1361 |
| Italy | 2011 | 1613 |
| Italy | 2012 | 1922 |
| Italy | 2013 | 1722 |
| Italy | 2014 | 1865 |
| Italy | 2015 | 1894 |
| Italy | 2016 | 1639 |
| Italy | 2017 | 918 |
| Japan | 2007 | 2913 |
| Japan | 2008 | 2374 |
| Japan | 2009 | 2253 |
| Japan | 2010 | 2225 |
| Japan | 2011 | 2172 |
| Japan | 2012 | 2030 |
| Japan | 2013 | 1755 |
| Japan | 2014 | 1664 |
| Japan | 2015 | 1553 |
| Japan | 2016 | 1481 |
| Japan | 2017 | 1077 |
| Mexico | 2007 | 4259 |
| Mexico | 2008 | 3680 |
| Mexico | 2009 | 3599 |
| Mexico | 2010 | 3260 |
| Mexico | 2011 | 3439 |
| Mexico | 2012 | 3602 |
| Mexico | 2013 | 2985 |
| Mexico | 2014 | 2769 |
| Mexico | 2015 | 2462 |
| Mexico | 2016 | 2315 |
| Mexico | 2017 | 2239 |
| Nepal | 2007 | 2775 |
| Nepal | 2008 | 2538 |
| Nepal | 2009 | 2724 |
| Nepal | 2010 | 2467 |
| Nepal | 2011 | 2169 |
| Nepal | 2012 | 2066 |
| Nepal | 2013 | 1788 |
| Nepal | 2014 | 1598 |
| Nepal | 2015 | 1512 |
| Nepal | 2016 | 1504 |
| Nepal | 2017 | 1249 |
| Pakistan | 2007 | 4259 |
| Pakistan | 2008 | 3803 |
| Pakistan | 2009 | 3683 |
| Pakistan | 2010 | 3012 |
| Pakistan | 2011 | 3033 |
| Pakistan | 2012 | 2765 |
| Pakistan | 2013 | 2381 |
| Pakistan | 2014 | 2497 |
| Pakistan | 2015 | 2512 |
| Pakistan | 2016 | 2401 |
| Pakistan | 2017 | 1536 |
| Philippines | 2007 | 12230 |
| Philippines | 2008 | 10713 |
| Philippines | 2009 | 10407 |
| Philippines | 2010 | 8887 |
| Philippines | 2011 | 9098 |
| Philippines | 2012 | 9400 |
| Philippines | 2013 | 7399 |
| Philippines | 2014 | 6772 |
| Philippines | 2015 | 4147 |
| Philippines | 2016 | 3704 |
| Philippines | 2017 | 3161 |
| Russia | 2007 | 2446 |
| Russia | 2008 | 1760 |
| Russia | 2009 | 1544 |
| Russia | 2010 | 1434 |
| Russia | 2011 | 1570 |
| Russia | 2012 | 1499 |
| Russia | 2013 | 1318 |
| Russia | 2014 | 1323 |
| Russia | 2015 | 1275 |
| Russia | 2016 | 1154 |
| Russia | 2017 | 948 |
| South Korea | 2007 | 10730 |
| South Korea | 2008 | 10277 |
| South Korea | 2009 | 10704 |
| South Korea | 2010 | 8721 |
| South Korea | 2011 | 7480 |
| South Korea | 2012 | 7204 |
| South Korea | 2013 | 5576 |
| South Korea | 2014 | 4897 |
| South Korea | 2015 | 4298 |
| South Korea | 2016 | 4269 |
| South Korea | 2017 | 3203 |
| Spain | 2007 | 1079 |
| Spain | 2008 | 974 |
| Spain | 2009 | 933 |
| Spain | 2010 | 1018 |
| Spain | 2011 | 1233 |
| Spain | 2012 | 1140 |
| Spain | 2013 | 1230 |
| Spain | 2014 | 1201 |
| Spain | 2015 | 1110 |
| Spain | 2016 | 1094 |
| Spain | 2017 | 861 |
| Taiwan | 2007 | 5394 |
| Taiwan | 2008 | 4088 |
| Taiwan | 2009 | 4308 |
| Taiwan | 2010 | 4325 |
| Taiwan | 2011 | 4511 |
| Taiwan | 2012 | 4172 |
| Taiwan | 2013 | 3520 |
| Taiwan | 2014 | 3267 |
| Taiwan | 2015 | 2555 |
| Taiwan | 2016 | 2287 |
| Taiwan | 2017 | 2200 |
| Turkey | 2007 | 2415 |
| Turkey | 2008 | 2028 |
| Turkey | 2009 | 2041 |
| Turkey | 2010 | 2023 |
| Turkey | 2011 | 2020 |
| Turkey | 2012 | 1966 |
| Turkey | 2013 | 1658 |
| Turkey | 2014 | 1665 |
| Turkey | 2015 | 1711 |
| Turkey | 2016 | 1709 |
| Turkey | 2017 | 1177 |
| United Kingdom | 2007 | 5105 |
| United Kingdom | 2008 | 4241 |
| United Kingdom | 2009 | 4270 |
| United Kingdom | 2010 | 3651 |
| United Kingdom | 2011 | 3241 |
| United Kingdom | 2012 | 3130 |
| United Kingdom | 2013 | 2330 |
| United Kingdom | 2014 | 1988 |
| United Kingdom | 2015 | 1697 |
| United Kingdom | 2016 | 1528 |
| United Kingdom | 2017 | 1783 |
| Venezuela | 2007 | 1262 |
| Venezuela | 2008 | 1159 |
| Venezuela | 2009 | 1302 |
| Venezuela | 2010 | 1299 |
| Venezuela | 2011 | 1398 |
| Venezuela | 2012 | 1540 |
| Venezuela | 2013 | 1370 |
| Venezuela | 2014 | 1339 |
| Venezuela | 2015 | 1247 |
| Venezuela | 2016 | 1208 |
| Venezuela | 2017 | 873 |
ggplot(Countriesyear, aes(Year, totalyear)) + geom_bar(stat = "identity", fill="#009E73") +ggtitle("Petitions for H1B Visas per year")
As you can see from the barplot, 2016 had the highest number of H1B Visa petitions overall