##Preliminaries

rm(list = ls())
aliens <- read.csv ("aliens.csv", header = TRUE, stringsAsFactors = TRUE)
source('special_functions.R')
my_sample <- make.my.sample(34252777, 30, aliens)

Question 1

5+3
## [1] 8
10-4
## [1] 6
3*6
## [1] 18
20/2
## [1] 10

##Question 2

round(56.781563, digits=3)
## [1] 56.782
round(56.781563, digits=1)
## [1] 56.8
tail(aliens)
##          ID age color     island  college income antennae    politics anxiety
## 9995   9995  54  Pink Nanspucket Ganymede 176000 Straight Democrulite      48
## 9996   9996  66  Blue      Blick   Europa  52000 Straight Republicant      52
## 9997   9997  33  Pink      Plume Callisto  89000 Straight Republicant      53
## 9998   9998  60  Pink Nanspucket Callisto  23000 Straight Independone      51
## 9999   9999  51  Blue      Blick   Europa  37000 Straight Republicant      39
## 10000 10000  24  Pink Nanspucket       Io  14000 Straight Democrulite      49
##       depression sociable control memory intelligence time1 time2 time3 food1
## 9995          90      115      73     84          115 11.89 11.12  9.91     7
## 9996         110       80      57     91          100  4.79  2.92  2.95     6
## 9997         108       92      74     99          108  3.71  2.88  3.89    11
## 9998         107       89      75     87          102  3.40  3.61  3.76     7
## 9999          92      108      64    106          109  6.58  6.45  5.18     6
## 10000         99      101      69    104          124  5.13  3.32  3.47     8
##       sleep food2 reasoning_trials
## 9995    6.2     8                4
## 9996    5.4     7                4
## 9997    5.5     5                2
## 9998    3.9    10                3
## 9999    5.9     9                2
## 10000   6.8     7                1

##Question 3

There are 10,000 individuals in this dataframe

##Question 4

There are 27 different variables if you are including the aliens ID number

class(aliens$income)
## [1] "numeric"
class(aliens$sleep)
## [1] "numeric"
class(aliens$politics)
## [1] "factor"
class(aliens$antennae)
## [1] "factor"

##Question 5 Both the alien’s income and sleep are numerical values. The alien’s income and sleep are both continuous variables because they can both take any numerical value. An alien’s income and sleep are both interval variable because there is an absolute zero, you could make zero dollars a year or get zero sleep in a night.

Both the aliens political views and antennae shape are factor variables which are the same thing as categorical variables.

##Question 6

I used the following code to be able to find the summary of one of the categories demonstrated by all the aliens within the population. This output demonstrates the average ages of all the aliens, and what the maximum and minimum ages are throughout the population. I am still confused on how to find multiple groups at one time and what certain arguments mean. For example, within the summary(help), they discuss the use of maxsum and quantile.type which I do not understand how to use.

summary(aliens$memory)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##   52.00   85.00   92.00   92.06   99.00  129.00

##Question 7 Most aliens come from the island Blink. Most aliens are independone. The highest sociable score is 167. The lowest memory score is 52.

##Question 8

summary(aliens$food.diff)
## Length  Class   Mode 
##      0   NULL   NULL
aliens$food.diff <- aliens$food1 - aliens$food2

This code is finding the average difference between how much the aliens ate during the first day of observation and the second day. The following data shows that there was a mean score of -0.0096 between how much the aliens ate the first day verses the second day of observation. The code above is meant to demonstrate how the aliens eating habits changed from the first and the second day.

##Question 9

summary(aliens$sociable.diff)
## Length  Class   Mode 
##      0   NULL   NULL
aliens$sociable.diff <- aliens$sociable - aliens$anxiety

The code I made above is meant to demonstrate the amount of social anxiety the average alien has. By taking their sociable score and subtracting how much anxiety they get, that creates their true anxiety score when they are in public. If an alien has a negative score, that means their anxiety is higher than their sociability, making them very socially anxious. If an alien has a very high score, that means anxiety affects them very little in their everyday life.

##Question 10

Most of the aliens from my sample come from Plume Island. Most of the aliens from my sample are Independone. The highest sociable score in my sample is 130 The lowest memory score from my sample is 68

summary(my_sample$memory)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##   68.00   80.25   89.50   91.00   99.00  115.00
my_sample_2 <- make.my.sample(34252778, 30, aliens)
summary(my_sample_2$politics)
## Democrulite Independone Republicant 
##          13           8           9

##Question 11 Most of the aliens from my second sample are from Plume Island. Most of the aliens from my second sample are Democrulite. The highest sociable score for my second sample is 124. The lowest memory score for my second sample is 73.

##Question 12 The island that the most aliens live on in the two samples is Plume island while the average of the entire population is Blink, in this case the sample does not accurately represent the total population for where the most aliens live.

The average political party for my first sample and the average population is Independone but for the second sample it is Democrulite, showing that the second sample does not accurately represent the total population in political views.

The highest sociable score for the samples is fairly close with only a difference of 6 points, but the highest sociable score within the entire population is 167, 37 points higher than my first sample of 130. This demonstrates that the samples are not accurate in figuring out the highest sociable score.

The lowest memory score between the two samples is 73 and 68, leaving only a difference of 7 points. There is a great difference between the samples and the lowest memory score throughout the population which is 52, leaving a difference of 16 points. The samples are close to the lowest memory score but not exact.