#1. Find your data.I asked chat gpt to create a data set for me #2. Import it into R Studio.

setwd("/Users/admin/Desktop")
data<-read.table("./2sample_data.csv", header = TRUE, sep =";", dec = ",")

#3. Display your data using the head function.

head(data)
##   Height..cm.             Name Age Weight..kg. Gender Marital.Status   Income
## 1         176      Linda Brown  23          79 Female        Widowed 36865.36
## 2         186   William Wilson  18          53   Male        Married 68953.22
## 3         182   Patricia Smith  56          76 Female       Divorced 50287.46
## 4         169  Jennifer Miller  30          62   Male         Single 94410.69
## 5         191   Jennifer Smith  62          85 Female        Widowed 85180.21
## 6         172 William Williams  39          90   Male        Married 80008.45

#4. Explain your data(what is the unit of observation,sample size,definition of all variables,units of measurement, etc.).

summary(data)
##   Height..cm.        Name                Age        Weight..kg.   
##  Min.   :150.0   Length:40          Min.   :18.0   Min.   :50.00  
##  1st Qu.:168.8   Class :character   1st Qu.:29.5   1st Qu.:56.75  
##  Median :177.5   Mode  :character   Median :44.0   Median :69.50  
##  Mean   :178.0                      Mean   :42.3   Mean   :71.75  
##  3rd Qu.:190.2                      3rd Qu.:54.5   3rd Qu.:88.25  
##  Max.   :198.0                      Max.   :63.0   Max.   :98.00  
##     Gender          Marital.Status         Income     
##  Length:40          Length:40          Min.   :31933  
##  Class :character   Class :character   1st Qu.:45359  
##  Mode  :character   Mode  :character   Median :67880  
##                                        Mean   :65751  
##                                        3rd Qu.:83298  
##                                        Max.   :99937

#Number of observations: 40 #Variabels: #Height.cm #Definition: The height of the individual. #Type:Numerical #Unit: Centimeters (cm).

#Definition: The name of the individual. #Type:Categorical

#Age #Definition: The age of the individual. #Type:Numerical #Unit: Years.

#Weight (kg) #Definition: The weight of the individual. #Type:Numerical #Unit: Kilograms (kg).

#Gender #Definition: The gender of the individual. #Type:Categorical #Unit: (Male/Female).

#Marital Status #Definition: The marital status of the individual. #Type:Categorical #Unit: (Single/Married/Divorced/Widowed).

#Income #Definition: The income of the individual. #Type:Numerical #Unit: Euros (€).

#5. Name the source of the data clearly. #Source: sample is generate by chat gpt

#6. Carry our data manipulation if necessary #There is no need to convert categorical variables into factors, as there are no those variables that are encoded with numerical code

#Present the descriptive statistics for the selected variables and explain at least 1 descriptive statistic (mean, median, coefficient of variation etc.) for each variable in your dataset.

summary(data$Height..cm.)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##   150.0   168.8   177.5   178.0   190.2   198.0
sd(data$Height..cm.)
## [1] 13.83694
library(psych)
describe(data$Height..cm.)
##    vars  n   mean    sd median trimmed   mad min max range  skew kurtosis   se
## X1    1 40 177.98 13.84  177.5  178.59 17.05 150 198    48 -0.27    -1.09 2.19
summary(data$Name)
##    Length     Class      Mode 
##        40 character character
summary(data$Age)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##    18.0    29.5    44.0    42.3    54.5    63.0
sd(data$Age)
## [1] 14.71821
describe(data$Age)
##    vars  n mean    sd median trimmed   mad min max range  skew kurtosis   se
## X1    1 40 42.3 14.72     44   42.69 17.79  18  63    45 -0.18    -1.32 2.33
summary(data$Weight..kg.)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##   50.00   56.75   69.50   71.75   88.25   98.00
sd(data$Weight..kg.)
## [1] 15.98517
describe(data$Weight..kg.)
##    vars  n  mean    sd median trimmed   mad min max range skew kurtosis   se
## X1    1 40 71.75 15.99   69.5   71.47 20.76  50  98    48 0.15    -1.49 2.53
summary(data$Gender)
##    Length     Class      Mode 
##        40 character character
summary(data$Marital.Status)
##    Length     Class      Mode 
##        40 character character
summary(data$Income)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##   31933   45359   67880   65751   83298   99937
sd(data$Income)
## [1] 20238.04
describe(data$Income)
##    vars  n     mean       sd   median  trimmed      mad      min      max
## X1    1 40 65750.62 20238.04 67880.16 65679.99 27871.88 31933.33 99937.46
##       range  skew kurtosis      se
## X1 68004.13 -0.07     -1.3 3199.91

#Description #Height: #The minimum height is 150 cm, while the maximum is 198. The mean (178) is a bit higher than the median (177.5), which means that the data is skewed to the right slightly. There is 25% of people in the data set, whose height is less or equal to 168.8.There is 75% of people in the data set, whose height is less or equal to 190.2. Standard deviation in 13,84, which means, that on average the values in the dataset deviate by 13,84 centimeters from its mean.

#Age #The minimum age is 18 years, while the maximum is 63. The mean (42.3) is a bit lower than the median (44), which means that the data is skewed to the left slightly. There is 25% of people in the data set, whose age is less or equal to 29.5 years.There is 75% of people in the data set, whose height is less or equal to 54.5. Standard deviation in 14,72, which means, that on average the values in the dataset deviate by 14,72, years from its mean.

#Weight #The minimum weight is 50 kilos, while the maximum is 98. The mean (71.75) is a higher than the median (69.5), which means that the data is skewed to the right slightly. There is 25% of people in the data set, whose weight is less or equal to 56.75 years.There is 75% of people in the data set, whose height is less or equal to 88.25. Standard deviation in 15.99, which means, that on average the values in the dataset deviate by around 16 kilos from its mean.

#Income #The minimum income is 31933 euros, while the maximum is 99937. The mean (65751) is a bit lower than the median (67880), which means that the data is skewed to the left slightly. There is 25% of people in the data set, whose income is less or equal to 45359 years.There is 75% of people in the data set, whose height is less or equal to 83298. Standard deviation in 20238.04 which means, that on average the values in the dataset deviate by 20238.04 euros from its mean.

#8. Graph the distribution of the variables using histograms, scatterplots, and/or boxplots. Explain the results clearly.

hist(data$Age, col = "blue", main = "Age Distribution", xlab = "Age", ylab = "Frequency")

#Age histogram: The histogram shows a fairly even distribution across different ages, with a slight concentration in the middle age range. This suggests a diverse age group in the sample.

plot(data$Age, data$Income, xlab = "Age", ylab="Income", main = "Dependance of Income on the age")

cor(data$Age, data$Income)
## [1] 0.0657287

#There is no dependane of Income on age evident. Considering the correlation coefficient of 0.0657287, it can be stated that Age and Income do not depend on each other

boxplot((data$Weight), col = "green", main = "Weight distribution", xlab ="Weight")

#For weight, the boxplot shows the median near 70 kg, with most data points falling between approximately 56 kg and 88 kg. The distribution of weight seems fairly normal with no extreme outliers.

title: “Homework 1” author: “Anastasiia Pryshchepa” date: “2024-04-07” output: html_document