HW2

Data reading and Basic Wrangling

Pragyanta Dhal
2022-05-12

Libraries

Reading Data

student <- read_csv("data.csv")
str(student)
spec_tbl_df [1,000 × 8] (S3: spec_tbl_df/tbl_df/tbl/data.frame)
 $ gender                     : chr [1:1000] "female" "female" "female" "male" ...
 $ race/ethnicity             : chr [1:1000] "group B" "group C" "group B" "group A" ...
 $ parental level of education: chr [1:1000] "bachelor's degree" "some college" "master's degree" "associate's degree" ...
 $ lunch                      : chr [1:1000] "standard" "standard" "standard" "free/reduced" ...
 $ test preparation course    : chr [1:1000] "none" "completed" "none" "none" ...
 $ math score                 : num [1:1000] 72 69 90 47 76 71 88 40 64 38 ...
 $ reading score              : num [1:1000] 72 90 95 57 78 83 95 43 64 60 ...
 $ writing score              : num [1:1000] 74 88 93 44 75 78 92 39 67 50 ...
 - attr(*, "spec")=
  .. cols(
  ..   gender = col_character(),
  ..   `race/ethnicity` = col_character(),
  ..   `parental level of education` = col_character(),
  ..   lunch = col_character(),
  ..   `test preparation course` = col_character(),
  ..   `math score` = col_double(),
  ..   `reading score` = col_double(),
  ..   `writing score` = col_double()
  .. )
 - attr(*, "problems")=<externalptr> 

Dataset variables

Columns:

  1. Gender - String
  2. Race/ethnicity - String
  3. Parental level of education - String
  4. Lunch - String
  5. Test preparation course - String
  6. Math score - Numeric
  7. Reading score - Numeric
  8. Writing score - Numeric

Basic Data Wrangling

Filtering female students and selecting only two columns to display

filter(student, `gender` == 'female') %>%
  select('gender', 'lunch')
# A tibble: 518 × 2
   gender lunch       
   <chr>  <chr>       
 1 female standard    
 2 female standard    
 3 female standard    
 4 female standard    
 5 female standard    
 6 female free/reduced
 7 female standard    
 8 female standard    
 9 female standard    
10 female free/reduced
# … with 508 more rows

Reuse

Text and figures are licensed under Creative Commons Attribution CC BY-NC 4.0. The figures that have been reused from other sources don't fall under this license and can be recognized by a note in their caption: "Figure from ...".

Citation

For attribution, please cite this work as

Dhal (2022, May 19). Data Analytics and Computational Social Science: HW2. Retrieved from https://github.com/DACSS/dacss_course_website/posts/httpsrpubscompdhal27hw2/

BibTeX citation

@misc{dhal2022hw2,
  author = {Dhal, Pragyanta},
  title = {Data Analytics and Computational Social Science: HW2},
  url = {https://github.com/DACSS/dacss_course_website/posts/httpsrpubscompdhal27hw2/},
  year = {2022}
}