# Name: Anneliesse A
# Student ID: 919324330

# Lab 3
# PSC 103A
# University of California, Davis

# Instructions: Enter your answers below each corresponding question header.
# Your code should produce the necessary outputs and/or plot based
# on what each question requests. 
# Make sure to answer the questions in Canvas directly depending on
# what is asked.


## Add any relevant library() commands below:


# Don't forget to comment out any install.packages()
# commands by using #,
# so that the report is generated is correctly
# without issues.



## Q1:

getwd()
## [1] "/Users/anneliessealcalde/Downloads"
assign2data <- read.table('/Users/anneliessealcalde/Desktop/PSC103A/assign2data.txt', header=T, stringsAsFactors =T)
str(assign2data)
## 'data.frame':    100 obs. of  4 variables:
##  $ Neuroticism : num  1.6 0.82 1.64 0.89 1.16 2.79 2.17 3.16 1.61 1.86 ...
##  $ Extraversion: num  3.9 2.5 3.91 4.09 2.63 2.19 2.31 2.2 2.84 3.65 ...
##  $ BioSex      : Factor w/ 2 levels "female","male": 2 2 2 1 1 1 2 1 1 1 ...
##  $ Housing     : Factor w/ 3 levels "Off Campus Alone",..: 3 3 2 2 2 2 3 2 2 2 ...
class(assign2data$Extraversion) 
## [1] "numeric"
# the variable Extraversion is numeric

## Q2:
#library(Hmisc)

mean_extraversion = mean(assign2data$Extraversion, na.rm=TRUE)
mean_extraversion
## [1] 2.8317
boxplot(assign2data$Extraversion, main = 'Extraversion Scale', ylab = 'Scores')
points(x = 1, y = mean_extraversion, col = "blue", pch = 16)

## Q3:

summary_extraversion = summary(assign2data$Extraversion)

range_extraversion = range(assign2data$Extraversion, na.rm = TRUE)

var_extraversion = var(assign2data$Extraversion, na.rm = TRUE)

sd_extraversion = sd(assign2data$Extraversion, na.rm = TRUE)

IQR_extraversion = IQR(assign2data$Extraversion, na.rm = TRUE)

summary_extraversion
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##   0.300   2.188   2.770   2.832   3.650   5.680
range_extraversion
## [1] 0.30 5.68
var_extraversion
## [1] 1.000503
sd_extraversion
## [1] 1.000252
IQR_extraversion
## [1] 1.4625
# In a sample of 100 observations, the Extraversion Scale boxplot represents the data findings which can help us understand the central tendency.
# From this boxplot we can see the mean of this data set is 2.83 (represented as a blue dot) with a median of 2.77. 
# Quadrant 1 is also found at 2.18 and quadrant 3 at 3.65.
# The minimum value of this whole data set is 0.30 and the maximum value is 5.68.

# From these values, we can determine the variability of this data set. 
# The range of this data set is 5.38. 
# The standard deviation is 1.00 and the IQR is 1.46. 
# Because there is no dot outside the box plot, we can assume there are no extreme outliers in this data set.

# Save your report as HTML, PDF or MS WORD (HTML is highly preferred)
# (Note: only compiled reports in one of these 3 formats will be accepted.
# A file that is shown to be 'corrupt' will be assigned a score of 0.)