rm(list = ls())
aliens_1_<- read.csv ("aliens (1).csv", header = TRUE, stringsAsFactors = TRUE)
source('special_functions.R')
my_sample <- make.my.sample(34331329, 30, aliens_1_)
##Question 1
6*3
## [1] 18
2+2
## [1] 4
3-1
## [1] 2
20/2
## [1] 10
round(56.781563, digits=3)
## [1] 56.782
round(56.781563,digits=1)
## [1] 56.8
head(aliens_1_)
## ID age color island college income antennae politics anxiety depression
## 1 1 33 Blue Blick Ganymede 27000 Curly Republicant 46 92
## 2 2 47 Pink Plume Ganymede 124000 Straight Independone 49 94
## 3 3 39 Pink Plume Io 43000 Straight Democrulite 51 119
## 4 4 24 Pink Blick Io 46000 Straight Republicant 45 92
## 5 5 53 Pink Blick Io 44000 Straight Democrulite 46 93
## 6 6 36 Blue Blick Europa 28000 Curly Republicant 49 98
## sociable control memory intelligence time1 time2 time3 food1 sleep food2
## 1 108 68 94 119 5.86 4.36 4.11 5 6.0 9
## 2 110 72 109 127 5.07 4.35 4.97 8 7.8 11
## 3 79 62 83 112 5.66 6.13 6.15 7 4.4 9
## 4 117 65 88 115 7.81 8.13 6.12 6 6.0 9
## 5 109 56 106 122 5.04 4.55 4.15 8 4.8 9
## 6 101 49 103 104 4.81 3.65 5.11 10 5.5 7
## reasoning_trials
## 1 1
## 2 1
## 3 1
## 4 1
## 5 1
## 6 1
tail(aliens_1_)
## 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
10,000 individuals represented
# Question 4
21 variables are respresented
# Question 5
```r
class(aliens_1_$age)
## [1] "integer"
class(aliens_1_$anxiety)
## [1] "integer"
class(aliens_1_$politics)
## [1] "factor"
class(aliens_1_$college)
## [1] "factor"
The two variables that are numerical are Age and Anxiety. For both anxiety and age, they are best regarded in continuous because each variable can have in between numbers. For examole, an alien can be 4.5 years of age and have 45.7 anxiety levels. Both age and anxiety would also be best regarded as intervals because each number under age and anxiety still mean the same thing. Whether it is how old the alien is or how much anxiety the alien has, the numbers all mean the same thing under the variable.
help("summary.data.frame")
#Question 6
summary.data.frame(aliens_1_)
## ID age color island college
## Min. : 1 Min. :10.00 Blue:3064 Blick :3504 Callisto:2472
## 1st Qu.: 2501 1st Qu.:26.00 Pink:6936 Nanspucket:3032 Europa :2533
## Median : 5000 Median :40.00 Plume :3464 Ganymede:2491
## Mean : 5000 Mean :40.21 Io :2504
## 3rd Qu.: 7500 3rd Qu.:55.00
## Max. :10000 Max. :70.00
## income antennae politics anxiety depression
## Min. : 5000 Curly :2155 Democrulite:3218 Min. :29 Min. : 65
## 1st Qu.: 34000 Straight:7845 Independone:3452 1st Qu.:47 1st Qu.: 93
## Median : 55000 Republicant:3330 Median :50 Median :100
## Mean : 69708 Mean :50 Mean :100
## 3rd Qu.: 90000 3rd Qu.:53 3rd Qu.:107
## Max. :559000 Max. :68 Max. :140
## sociable control memory intelligence
## Min. : 35.00 Min. :21.00 Min. : 52.00 Min. : 78.0
## 1st Qu.: 94.00 1st Qu.:53.00 1st Qu.: 85.00 1st Qu.:101.0
## Median :100.00 Median :60.00 Median : 92.00 Median :109.0
## Mean : 99.99 Mean :60.07 Mean : 92.06 Mean :108.5
## 3rd Qu.:106.00 3rd Qu.:67.00 3rd Qu.: 99.00 3rd Qu.:116.0
## Max. :167.00 Max. :96.00 Max. :129.00 Max. :135.0
## time1 time2 time3 food1
## Min. : 1.740 Min. : 0.570 Min. : 0.280 Min. : 1.000
## 1st Qu.: 5.130 1st Qu.: 4.290 1st Qu.: 4.298 1st Qu.: 7.000
## Median : 6.170 Median : 5.490 Median : 5.490 Median : 9.000
## Mean : 6.615 Mean : 5.867 Mean : 5.867 Mean : 8.665
## 3rd Qu.: 7.620 3rd Qu.: 6.990 3rd Qu.: 6.970 3rd Qu.:10.000
## Max. :24.890 Max. :23.420 Max. :25.300 Max. :17.000
## sleep food2 reasoning_trials
## Min. :2.500 Min. : 0.000 Min. : 1.000
## 1st Qu.:5.400 1st Qu.: 7.000 1st Qu.: 1.000
## Median :6.000 Median : 9.000 Median : 2.000
## Mean :6.012 Mean : 8.674 Mean : 2.958
## 3rd Qu.:6.700 3rd Qu.:10.000 3rd Qu.: 4.000
## Max. :9.500 Max. :16.000 Max. :27.000
This output shows the mean, median, maximun value, minimum value, lowest quartile and third quartile values of each value. Minimum value is the lowest data point. The first or lowest quartile is values that is under 25% of the data. The third or the upper quartile represents most of the data under that variable ( 75%), but don’t get it confused with the maximum value, which is just the higest data point. Mean is the average value in the data set. Median isis the middle value in the data. Length is how many aliens are involved in the data. Class is what the variable in classifed as, character simply means categorical for this data set. Mode is the same as class.
Blick is majority of where the aliens are from Independence is the popular political party Highest socialbility score is 167.00 lowest memory score is 52.00
This code gave e the data frame and console of the aliens data and the food difference between food 1 and food 2.
aliens_1_$food.diff <- aliens_1_$food1 - aliens_1_$food2
head(aliens_1_)
## ID age color island college income antennae politics anxiety depression
## 1 1 33 Blue Blick Ganymede 27000 Curly Republicant 46 92
## 2 2 47 Pink Plume Ganymede 124000 Straight Independone 49 94
## 3 3 39 Pink Plume Io 43000 Straight Democrulite 51 119
## 4 4 24 Pink Blick Io 46000 Straight Republicant 45 92
## 5 5 53 Pink Blick Io 44000 Straight Democrulite 46 93
## 6 6 36 Blue Blick Europa 28000 Curly Republicant 49 98
## sociable control memory intelligence time1 time2 time3 food1 sleep food2
## 1 108 68 94 119 5.86 4.36 4.11 5 6.0 9
## 2 110 72 109 127 5.07 4.35 4.97 8 7.8 11
## 3 79 62 83 112 5.66 6.13 6.15 7 4.4 9
## 4 117 65 88 115 7.81 8.13 6.12 6 6.0 9
## 5 109 56 106 122 5.04 4.55 4.15 8 4.8 9
## 6 101 49 103 104 4.81 3.65 5.11 10 5.5 7
## reasoning_trials food.diff
## 1 1 -4
## 2 1 -3
## 3 1 -2
## 4 1 -3
## 5 1 -1
## 6 1 3
summary.data.frame(aliens_1_)
## ID age color island college
## Min. : 1 Min. :10.00 Blue:3064 Blick :3504 Callisto:2472
## 1st Qu.: 2501 1st Qu.:26.00 Pink:6936 Nanspucket:3032 Europa :2533
## Median : 5000 Median :40.00 Plume :3464 Ganymede:2491
## Mean : 5000 Mean :40.21 Io :2504
## 3rd Qu.: 7500 3rd Qu.:55.00
## Max. :10000 Max. :70.00
## income antennae politics anxiety depression
## Min. : 5000 Curly :2155 Democrulite:3218 Min. :29 Min. : 65
## 1st Qu.: 34000 Straight:7845 Independone:3452 1st Qu.:47 1st Qu.: 93
## Median : 55000 Republicant:3330 Median :50 Median :100
## Mean : 69708 Mean :50 Mean :100
## 3rd Qu.: 90000 3rd Qu.:53 3rd Qu.:107
## Max. :559000 Max. :68 Max. :140
## sociable control memory intelligence
## Min. : 35.00 Min. :21.00 Min. : 52.00 Min. : 78.0
## 1st Qu.: 94.00 1st Qu.:53.00 1st Qu.: 85.00 1st Qu.:101.0
## Median :100.00 Median :60.00 Median : 92.00 Median :109.0
## Mean : 99.99 Mean :60.07 Mean : 92.06 Mean :108.5
## 3rd Qu.:106.00 3rd Qu.:67.00 3rd Qu.: 99.00 3rd Qu.:116.0
## Max. :167.00 Max. :96.00 Max. :129.00 Max. :135.0
## time1 time2 time3 food1
## Min. : 1.740 Min. : 0.570 Min. : 0.280 Min. : 1.000
## 1st Qu.: 5.130 1st Qu.: 4.290 1st Qu.: 4.298 1st Qu.: 7.000
## Median : 6.170 Median : 5.490 Median : 5.490 Median : 9.000
## Mean : 6.615 Mean : 5.867 Mean : 5.867 Mean : 8.665
## 3rd Qu.: 7.620 3rd Qu.: 6.990 3rd Qu.: 6.970 3rd Qu.:10.000
## Max. :24.890 Max. :23.420 Max. :25.300 Max. :17.000
## sleep food2 reasoning_trials food.diff
## Min. :2.500 Min. : 0.000 Min. : 1.000 Min. :-11.0000
## 1st Qu.:5.400 1st Qu.: 7.000 1st Qu.: 1.000 1st Qu.: -2.0000
## Median :6.000 Median : 9.000 Median : 2.000 Median : 0.0000
## Mean :6.012 Mean : 8.674 Mean : 2.958 Mean : -0.0096
## 3rd Qu.:6.700 3rd Qu.:10.000 3rd Qu.: 4.000 3rd Qu.: 2.0000
## Max. :9.500 Max. :16.000 Max. :27.000 Max. : 11.0000
## About this document
aliens_1_$anxiety.diff<- aliens_1_$age- aliens_1_$anxiety
summary (aliens_1_$anxiety.diff<- aliens_1_$age- aliens_1_$anxiety)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## -52.000 -25.000 -10.000 -9.791 5.000 31.000
I did the difference between age and anxiety. The values of the mean, min, median, 1st quartile, 3rd quartile, and max are both related to age and axniety; I implied that there is a relationship between the two and the data is using the values to show the relationship.
summary (my_sample <- make.my.sample(34331329, 30, aliens_1_))
## ID age color island college
## Min. : 516 Min. :11.00 Blue:10 Blick : 8 Callisto: 7
## 1st Qu.:2501 1st Qu.:22.00 Pink:20 Nanspucket:10 Europa : 7
## Median :5050 Median :32.00 Plume :12 Ganymede: 6
## Mean :4897 Mean :34.00 Io :10
## 3rd Qu.:7259 3rd Qu.:50.75
## Max. :9400 Max. :59.00
## income antennae politics anxiety
## Min. : 23000 Curly : 8 Democrulite:10 Min. :41.00
## 1st Qu.: 33750 Straight:22 Independone:11 1st Qu.:45.00
## Median : 51000 Republicant: 9 Median :50.00
## Mean : 67733 Mean :49.53
## 3rd Qu.: 94500 3rd Qu.:52.75
## Max. :166000 Max. :58.00
## depression sociable control memory
## Min. : 72.00 Min. : 72.00 Min. :41.0 Min. : 62.00
## 1st Qu.: 88.75 1st Qu.: 97.25 1st Qu.:54.0 1st Qu.: 88.25
## Median : 95.50 Median :103.00 Median :56.5 Median : 94.00
## Mean : 95.90 Mean :103.30 Mean :58.5 Mean : 93.87
## 3rd Qu.:103.00 3rd Qu.:107.75 3rd Qu.:65.0 3rd Qu.:100.50
## Max. :128.00 Max. :151.00 Max. :87.0 Max. :119.00
## intelligence time1 time2 time3
## Min. : 85.0 Min. : 2.260 Min. : 1.880 Min. : 1.580
## 1st Qu.:104.2 1st Qu.: 5.330 1st Qu.: 3.688 1st Qu.: 4.612
## Median :111.0 Median : 5.940 Median : 5.275 Median : 5.865
## Mean :109.6 Mean : 6.469 Mean : 5.468 Mean : 5.951
## 3rd Qu.:116.8 3rd Qu.: 7.143 3rd Qu.: 6.835 3rd Qu.: 7.043
## Max. :126.0 Max. :12.550 Max. :12.090 Max. :11.010
## food1 sleep food2 reasoning_trials
## Min. : 5.000 Min. :4.100 Min. : 5.000 Min. :1.000
## 1st Qu.: 7.000 1st Qu.:5.425 1st Qu.: 8.000 1st Qu.:1.000
## Median : 8.000 Median :5.850 Median : 9.500 Median :2.000
## Mean : 8.533 Mean :6.000 Mean : 9.433 Mean :2.533
## 3rd Qu.: 9.750 3rd Qu.:6.775 3rd Qu.:11.750 3rd Qu.:3.750
## Max. :12.000 Max. :7.400 Max. :13.000 Max. :9.000
## food.diff anxiety.diff
## Min. :-6.00 Min. :-47.00
## 1st Qu.:-3.75 1st Qu.:-28.00
## Median :-1.50 Median :-15.00
## Mean :-0.90 Mean :-15.53
## 3rd Qu.: 1.00 3rd Qu.: -1.25
## Max. : 7.00 Max. : 18.00
Plume is the most common island Independence is the popular political party Highest socialbility score is 151.00 lowest memory score is 62.00
my_sample_2 <- make.my.sample(34331330, 30, aliens_1_)
summary.data.frame(my_sample_2)
## ID age color island college
## Min. : 260 Min. :10.0 Blue: 7 Blick : 9 Callisto:10
## 1st Qu.:3133 1st Qu.:27.0 Pink:23 Nanspucket:11 Europa : 6
## Median :5067 Median :37.0 Plume :10 Ganymede: 8
## Mean :5213 Mean :38.6 Io : 6
## 3rd Qu.:7932 3rd Qu.:55.0
## Max. :9359 Max. :68.0
## income antennae politics anxiety
## Min. : 19000 Curly : 3 Democrulite: 8 Min. :39.00
## 1st Qu.: 32750 Straight:27 Independone:11 1st Qu.:48.00
## Median : 51500 Republicant:11 Median :50.00
## Mean : 70233 Mean :50.77
## 3rd Qu.: 88750 3rd Qu.:54.75
## Max. :269000 Max. :61.00
## depression sociable control memory
## Min. : 80.00 Min. : 85.0 Min. :44.00 Min. : 74.00
## 1st Qu.: 94.25 1st Qu.: 93.0 1st Qu.:53.50 1st Qu.: 89.50
## Median :100.50 Median :100.5 Median :59.50 Median : 98.50
## Mean :100.57 Mean :101.1 Mean :59.57 Mean : 95.13
## 3rd Qu.:107.75 3rd Qu.:106.8 3rd Qu.:64.00 3rd Qu.:102.00
## Max. :117.00 Max. :136.0 Max. :84.00 Max. :113.00
## intelligence time1 time2 time3
## Min. : 88.0 Min. : 3.870 Min. :1.940 Min. : 2.630
## 1st Qu.:104.0 1st Qu.: 5.080 1st Qu.:4.173 1st Qu.: 4.310
## Median :107.0 Median : 6.380 Median :6.325 Median : 5.950
## Mean :109.5 Mean : 6.701 Mean :6.030 Mean : 6.050
## 3rd Qu.:117.8 3rd Qu.: 7.947 3rd Qu.:7.715 3rd Qu.: 7.303
## Max. :126.0 Max. :11.560 Max. :9.850 Max. :10.200
## food1 sleep food2 reasoning_trials
## Min. : 5.000 Min. :4.000 Min. : 6 Min. : 1.000
## 1st Qu.: 7.000 1st Qu.:5.125 1st Qu.: 8 1st Qu.: 1.000
## Median : 8.500 Median :5.650 Median : 9 Median : 1.000
## Mean : 8.533 Mean :5.760 Mean : 9 Mean : 2.467
## 3rd Qu.:10.000 3rd Qu.:6.400 3rd Qu.:10 3rd Qu.: 2.750
## Max. :12.000 Max. :9.000 Max. :14 Max. :13.000
## food.diff anxiety.diff
## Min. :-6.0000 Min. :-42.00
## 1st Qu.:-2.0000 1st Qu.:-25.25
## Median :-1.0000 Median : -8.50
## Mean :-0.4667 Mean :-12.17
## 3rd Qu.: 2.0000 3rd Qu.: 1.50
## Max. : 4.0000 Max. : 17.00
#Question 11 Nanspucket is the common island Independence and republicant is tied Highest socialbility score is 136.0 lowest memory score is 74.00
#Question 12 Both population have similarities such as political party. Althought sample two tied Republicant and Independence, in the first sampel independence was the highest. However, Plume is the common island that the aliens are from in sample 1, sample 2 it is Nanspucket. The highest socialblility score is lower in sample 2 compared to sample 1. The lowest memory is lower in sample 2 as well, compared to sample 1. I beleive sample 2 has a bigger population because of the plus 1. Because of the plus one, my data noticebly changed; clarifying that sample 2 captures more of the data compared to sample 1.