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.
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(tidyverse)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ forcats   1.0.1     ✔ readr     2.2.0
## ✔ ggplot2   4.0.3     ✔ stringr   1.6.0
## ✔ lubridate 1.9.5     ✔ tibble    3.3.1
## ✔ purrr     1.2.2     ✔ tidyr     1.3.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

Instructions:

Read the StudentSurvey into this markdown and answers the following questions

#read the StudentSurvey.csv in here
setwd("/Users/cassidystauffer/Documents/MCCC/Data 101/Week 2/")
df <- 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.

Check the data structure:

#check the head of the data set

head(df)
## # 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(df)
## [1] 79 17
#create a table of students'sex and "HigherSAT"

v1 <- df[, c("Sex", "HigherSAT")]
v1
## # A tibble: 79 × 2
##    Sex   HigherSAT
##    <chr> <chr>    
##  1 M     Math     
##  2 F     Math     
##  3 M     Math     
##  4 M     Math     
##  5 F     Verbal   
##  6 F     Verbal   
##  7 F     Math     
##  8 M     Math     
##  9 F     Math     
## 10 F     Math     
## # ℹ 69 more rows
# Display summary statistics for VerbalSAT

summary(df["VerbalSAT"])
##    VerbalSAT    
##  Min.   :420.0  
##  1st Qu.:550.0  
##  Median :580.0  
##  Mean   :583.2  
##  3rd Qu.:630.0  
##  Max.   :720.0
#Find the average GPA of students

gpa_avg <-mean(df$"GPA")

gpa_avg
## [1] 3.169114
#Create a new dataframe, call it "column_df". This new dataframe should contain students' weight and number of hours the exercise 

column_df <- data.frame(df$Exercise, df$Weight)

column_df
##    df.Exercise df.Weight
## 1           10       180
## 2            4       120
## 3           14       208
## 4            3       110
## 5            3       150
## 6            5       114
## 7           10       128
## 8           13       235
## 9           12       115
## 10          12       140
## 11           6       135
## 12          10       110
## 13           3        99
## 14           7       165
## 15           2       120
## 16          14       154
## 17          10       110
## 18          14       145
## 19          20       195
## 20           7       200
## 21          12       167
## 22          10       175
## 23           6       155
## 24          14       185
## 25          12       190
## 26          10       165
## 27           8       175
## 28           0       126
## 29          10       187
## 30           6       170
## 31           5       158
## 32          24       119
## 33           2       205
## 34          10       129
## 35           6       145
## 36           5       130
## 37           5       215
## 38          12       135
## 39           2       145
## 40           7        98
## 41          15       150
## 42           5       159
## 43           7       174
## 44          15       160
## 45           8       165
## 46          14       161
## 47           4       130
## 48          15       175
## 49           4       255
## 50          15       160
## 51           3       160
## 52           3        95
## 53          15       115
## 54          20       120
## 55           3       135
## 56           6       180
## 57          12       155
## 58           4       110
## 59          20       215
## 60          10       140
## 61          10       195
## 62           4       185
## 63           9       185
## 64          12       209
## 65           2       145
## 66           2       180
## 67           5       170
## 68           5       135
## 69           6       165
## 70          10       137
## 71           4       147
## 72           5       150
## 73          17       155
## 74           7       160
## 75           2       130
## 76           8       180
## 77           1       150
## 78          14       205
## 79          12       115
#Access the fourth element in the first column from the StudentSurvey's dataset.

df[4,1]
## # A tibble: 1 × 1
##   Year  
##   <chr> 
## 1 Junior