Set the working directory:

  1. Download “StudentSurvey.csv” to your computer.
  2. Set Working directory to the folder you saved your file in.
  3. read the file using read.csv command.
#If your assignment does not render, you might need to install.packages("htmltools")

Instructions:

Read the StudentSurvey into this markdown and answers the following questions

#read the StudentSurvey.csv in here
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.2
## ✔ ggplot2   4.0.0     ✔ tibble    3.3.0
## ✔ lubridate 1.9.4     ✔ tidyr     1.3.1
## ✔ purrr     1.1.0     
## ── 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
setwd("C:/Users/njnav/OneDrive/Data 101/Week 2/Import")
survey <- read_csv("StudentSurvey.csv")
## Rows: 79 Columns: 17
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr  (5): Year, Sex, Smoke, Award, HigherSAT
## dbl (12): Exercise, TV, Height, Weight, Siblings, BirthOrder, VerbalSAT, Mat...
## 
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
#Thanks for the help here

Check the data structure:

#check the head of the data set
head(survey)
## # A tibble: 6 × 17
##   Year      Sex   Smoke Award   HigherSAT Exercise    TV Height Weight Siblings
##   <chr>     <chr> <chr> <chr>   <chr>        <dbl> <dbl>  <dbl>  <dbl>    <dbl>
## 1 Senior    M     No    Olympic Math            10     1     71    180        4
## 2 Sophomore F     Yes   Academy Math             4     7     66    120        2
## 3 FirstYear M     No    Nobel   Math            14     5     72    208        2
## 4 Junior    M     No    Nobel   Math             3     1     63    110        1
## 5 Sophomore F     No    Nobel   Verbal           3     3     65    150        1
## 6 Sophomore F     No    Nobel   Verbal           5     4     65    114        2
## # ℹ 7 more variables: BirthOrder <dbl>, VerbalSAT <dbl>, MathSAT <dbl>,
## #   SAT <dbl>, GPA <dbl>, Pulse <dbl>, Piercings <dbl>
#check the dimensions
dim(survey)
## [1] 79 17
#create a table of students'sex and "HigherSAT"
xtabs(~ Sex + HigherSAT, data=survey)
##    HigherSAT
## Sex Math Verbal
##   F   25     15
##   M   24     15
table(survey$Sex, survey$HigherSAT)
##    
##     Math Verbal
##   F   25     15
##   M   24     15
table(survey$HigherSAT, survey$Sex)
##         
##           F  M
##   Math   25 24
##   Verbal 15 15
# Display summary statistics for VerbalSAT
summary(survey$VerbalSAT)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##   420.0   550.0   580.0   583.2   630.0   720.0
#Find the average GPA of students
mean(survey$GPA)
## [1] 3.169114
#Create a new dataframe, call it "column_df". This new dataframe should contain students' weight and number of hours the exercise 
Weight <- c(survey$Weight)
Hours_Exercise <- c(survey$Exercise)
column_df <- data.frame(Weight, Hours_Exercise)
column_df
##    Weight Hours_Exercise
## 1     180             10
## 2     120              4
## 3     208             14
## 4     110              3
## 5     150              3
## 6     114              5
## 7     128             10
## 8     235             13
## 9     115             12
## 10    140             12
## 11    135              6
## 12    110             10
## 13     99              3
## 14    165              7
## 15    120              2
## 16    154             14
## 17    110             10
## 18    145             14
## 19    195             20
## 20    200              7
## 21    167             12
## 22    175             10
## 23    155              6
## 24    185             14
## 25    190             12
## 26    165             10
## 27    175              8
## 28    126              0
## 29    187             10
## 30    170              6
## 31    158              5
## 32    119             24
## 33    205              2
## 34    129             10
## 35    145              6
## 36    130              5
## 37    215              5
## 38    135             12
## 39    145              2
## 40     98              7
## 41    150             15
## 42    159              5
## 43    174              7
## 44    160             15
## 45    165              8
## 46    161             14
## 47    130              4
## 48    175             15
## 49    255              4
## 50    160             15
## 51    160              3
## 52     95              3
## 53    115             15
## 54    120             20
## 55    135              3
## 56    180              6
## 57    155             12
## 58    110              4
## 59    215             20
## 60    140             10
## 61    195             10
## 62    185              4
## 63    185              9
## 64    209             12
## 65    145              2
## 66    180              2
## 67    170              5
## 68    135              5
## 69    165              6
## 70    137             10
## 71    147              4
## 72    150              5
## 73    155             17
## 74    160              7
## 75    130              2
## 76    180              8
## 77    150              1
## 78    205             14
## 79    115             12
#Access the fourth element in the first column from the StudentSurvey's dataset.
survey[4,1]
## # A tibble: 1 × 1
##   Year  
##   <chr> 
## 1 Junior