Lab 1: Using LNS to practice creating HTMLs.

Pre-lab Procedures

Load Necessary packages

library(tidyverse)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr     1.1.4     ✔ readr     2.1.5
## ✔ forcats   1.0.0     ✔ stringr   1.5.1
## ✔ ggplot2   3.4.4     ✔ tibble    3.2.1
## ✔ lubridate 1.9.3     ✔ tidyr     1.3.1
## ✔ purrr     1.0.2     
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag()    masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(haven)

Load LNS data

Code to load LNS data into R

LNS <-read_dta(url("https://github.com/angelaxocampo/SSM/raw/main/Lab_1/Data/LNS.dta"))

Exercises:

Exercise 1:

LNS %>% count(REDUC)
## # A tibble: 8 × 2
##   REDUC                               n
##   <chr>                           <int>
## 1 4 year college degree             818
## 2 Eighth grade or below            1714
## 3 GED                               286
## 4 Graduate or professional degree   582
## 5 High school graduate             2110
## 6 None                              222
## 7 Some college                     1646
## 8 Some high school                 1256
LNS %>% count(REDUC) %>% mutate(pct= prop.table(n) * 100 )
## # A tibble: 8 × 3
##   REDUC                               n   pct
##   <chr>                           <int> <dbl>
## 1 4 year college degree             818  9.47
## 2 Eighth grade or below            1714 19.9 
## 3 GED                               286  3.31
## 4 Graduate or professional degree   582  6.74
## 5 High school graduate             2110 24.4 
## 6 None                              222  2.57
## 7 Some college                     1646 19.1 
## 8 Some high school                 1256 14.5
ggplot(LNS, aes(REDUC)) + geom_bar() + theme(axis.text.x=(element_text(angle=90)))

Education_Level_Bar_Graph We can see here that the education levels of Latinos within the survey vary in degrees of completion. 37% of Latinos did not graduate with a high school degree, while the other 63% of Latinos have some sort of GED/HS degree or higher education. 24.4% of Latinos have a high school degree which makes up the most frequent response, and 2.6% of Latinos do not have any formal education, making up the least frequent response.

Exercise 2:

LNS %>% count(ANCESTRY) %>% mutate(pct= prop.table(n) * 100 ) %>% print(n = 23)
## # A tibble: 23 × 3
##    ANCESTRY               n     pct
##    <chr>              <int>   <dbl>
##  1 Argentina             28  0.324 
##  2 Bolivia               36  0.417 
##  3 Chile                 17  0.197 
##  4 Colombia             139  1.61  
##  5 Costa Rica            32  0.371 
##  6 Cuba                 420  4.86  
##  7 Dominican Republic   335  3.88  
##  8 Don't Know            30  0.347 
##  9 Ecuador              103  1.19  
## 10 El Salvador          407  4.71  
## 11 Guatemala            149  1.73  
## 12 Honduras              87  1.01  
## 13 Mexico              5704 66.1   
## 14 Nicaragua             51  0.591 
## 15 Panama                14  0.162 
## 16 Paraguay               3  0.0347
## 17 Peru                  65  0.753 
## 18 Puerto Rico          822  9.52  
## 19 Refused               18  0.208 
## 20 Spain                105  1.22  
## 21 USA                   35  0.405 
## 22 Uruguay                7  0.0811
## 23 Venezuela             27  0.313

The most common country that the respondents trace their origin back to is Mexico; the least common is Paraguay. I think the most surprising thing that I observed from the data was that there wasn’t many people that trace their ancestry back to a country that wasn’t mexico. This makes me wonder exactly where the survey was taken, if it was taken closer to border states, I would be inclined to think that the location has a major effect on the data.

Exercise 3:

LNS %>% count(BORNUS) %>% mutate(pct= prop.table(n) * 100 ) 
## # A tibble: 3 × 3
##   BORNUS                 n   pct
##   <chr>              <int> <dbl>
## 1 Mainland U.S.       2450 28.4 
## 2 Puerto Rico          467  5.41
## 3 Some other country  5717 66.2

There is 5.41% of respondents that are born on Puerto Rico. 66.2% of the respondents were born in some other country other than Puerto Rico and/or the Mainland U.S.


Exercise 4:

ggplot(LNS, aes(LANGPREF)) + geom_bar()

Language Preferance Bar Graph The most preferred language spoken by the respondents of the LNS is Spanish at 61.9% of the total respondents. The other preferred language was english at 38.1% of the total respondents.