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
studentservey_df<- read.csv("StudentSurvey.csv")

Check the data structure:

#check the head of the data set
head(studentservey_df)
##        Year Sex Smoke   Award HigherSAT Exercise TV Height Weight Siblings
## 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
##   BirthOrder VerbalSAT MathSAT  SAT  GPA Pulse Piercings
## 1          4       540     670 1210 3.13    54         0
## 2          2       520     630 1150 2.50    66         3
## 3          1       550     560 1110 2.55   130         0
## 4          1       490     630 1120 3.10    78         0
## 5          1       720     450 1170 2.70    40         6
## 6          2       600     550 1150 3.20    80         4
#check the dimensions
str(studentservey_df)
## 'data.frame':    79 obs. of  17 variables:
##  $ Year      : chr  "Senior" "Sophomore" "FirstYear" "Junior" ...
##  $ Sex       : chr  "M" "F" "M" "M" ...
##  $ Smoke     : chr  "No" "Yes" "No" "No" ...
##  $ Award     : chr  "Olympic" "Academy" "Nobel" "Nobel" ...
##  $ HigherSAT : chr  "Math" "Math" "Math" "Math" ...
##  $ Exercise  : int  10 4 14 3 3 5 10 13 12 12 ...
##  $ TV        : int  1 7 5 1 3 4 10 8 1 6 ...
##  $ Height    : int  71 66 72 63 65 65 66 74 60 65 ...
##  $ Weight    : int  180 120 208 110 150 114 128 235 115 140 ...
##  $ Siblings  : int  4 2 2 1 1 2 1 1 7 1 ...
##  $ BirthOrder: int  4 2 1 1 1 2 1 1 8 2 ...
##  $ VerbalSAT : int  540 520 550 490 720 600 640 660 670 500 ...
##  $ MathSAT   : int  670 630 560 630 450 550 680 710 700 670 ...
##  $ SAT       : int  1210 1150 1110 1120 1170 1150 1320 1370 1370 1170 ...
##  $ GPA       : num  3.13 2.5 2.55 3.1 2.7 3.2 2.77 3.3 3.7 2.09 ...
##  $ Pulse     : int  54 66 130 78 40 80 94 77 94 63 ...
##  $ Piercings : int  0 3 0 0 6 4 8 0 2 2 ...
str(studentservey_df$Year)
##  chr [1:79] "Senior" "Sophomore" "FirstYear" "Junior" "Sophomore" ...
dim(studentservey_df)
## [1] 79 17
head(studentservey_df)
##        Year Sex Smoke   Award HigherSAT Exercise TV Height Weight Siblings
## 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
##   BirthOrder VerbalSAT MathSAT  SAT  GPA Pulse Piercings
## 1          4       540     670 1210 3.13    54         0
## 2          2       520     630 1150 2.50    66         3
## 3          1       550     560 1110 2.55   130         0
## 4          1       490     630 1120 3.10    78         0
## 5          1       720     450 1170 2.70    40         6
## 6          2       600     550 1150 3.20    80         4
head(studentservey_df$Award, 10)
##  [1] "Olympic" "Academy" "Nobel"   "Nobel"   "Nobel"   "Nobel"   "Olympic"
##  [8] "Olympic" "Nobel"   "Olympic"
tail(studentservey_df$Award)
## [1] "Nobel"   "Nobel"   "Olympic" "Nobel"   "Olympic" "Olympic"
summary(studentservey_df$VerbalSAT) 
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##   420.0   550.0   580.0   583.2   630.0   720.0
#create a table of students'sex and "HigherSAT"
xtabs(~ Sex + HigherSAT, data = studentservey_df)
##    HigherSAT
## Sex Math Verbal
##   F   25     15
##   M   24     15
table(studentservey_df$Sex, studentservey_df$HigherSAT)
##    
##     Math Verbal
##   F   25     15
##   M   24     15
table(studentservey_df$HigherSAT, studentservey_df$Sex)
##         
##           F  M
##   Math   25 24
##   Verbal 15 15
# Display summary statistics for VerbalSAT
summary(studentservey_df$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(studentservey_df$GPA, na.rm = TRUE) 
## [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 <- head(studentservey_df[, c("Weight", "Exercise")]); column_df
##   Weight Exercise
## 1    180       10
## 2    120        4
## 3    208       14
## 4    110        3
## 5    150        3
## 6    114        5
#Access the fourth element in the first column from the StudentSurvey's dataset.
studentservey_df$Year[4]
## [1] "Junior"