In this dataset, the space missions are recorded for each astronaut. It contains 1,270 observations and 20 columns. I got the dataset from “CSV” website and the source for the dataset is Mendeley.
This dataset contains information about astronauts, including their gender, nationality, birth year, mission roles, mission years, and mission durations. Each observation represents a mission record. Some astronauts appear more than once because they participated in multiple missions.
I used the most common library called “dplyr” for my cleaning and data analysis. I lower-cased and removed space from my variables, then renamed the variables I need for the project. I also filtered the NA values directly.
# Loading libraries and data
library(readr)
## Warning: package 'readr' was built under R version 4.6.1
library(dplyr)
## Warning: package 'dplyr' was built under R version 4.6.1
##
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
library(tidyverse)
## Warning: package 'tidyr' was built under R version 4.6.1
## Warning: package 'forcats' was built under R version 4.6.1
## Warning: package 'lubridate' was built under R version 4.6.1
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ forcats 1.0.1 ✔ stringr 1.6.0
## ✔ ggplot2 4.0.3 ✔ tibble 3.3.1
## ✔ lubridate 1.9.5 ✔ tidyr 1.3.2
## ✔ purrr 1.2.2
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag() masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
astr <- read_csv("C:/Users/a/Downloads/Dataset/astronauts.csv")
## Rows: 1270 Columns: 20
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (9): Profile.Name, Profile.Gender, Profile.Nationality, Profile.Selecti...
## dbl (10): Profile.Astronaut Numbers.Overall, Profile.Astronaut Numbers.Natio...
## lgl (1): Profile.Military
##
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
# Lowercase, removing space, renaming and filtering
names(astr) <- tolower(names(astr))
names(astr) <- gsub(" ", "_", names(astr))
names(astr) <- gsub("\\.", "_", names(astr))
astr <- astr |>
rename(name = profile_name,
gender = profile_gender,
mission = mission_name,
duration = mission_durations_mission_duration) |>
mutate(gender = as.factor(gender)) |>
filter(!is.na(duration) & !is.na(gender))
names(astr)
## [1] "profile_astronaut_numbers_overall"
## [2] "profile_astronaut_numbers_nationwide"
## [3] "name"
## [4] "gender"
## [5] "profile_birth_year"
## [6] "profile_nationality"
## [7] "profile_military"
## [8] "profile_selection_group"
## [9] "profile_selection_year"
## [10] "profile_lifetime_statistics_mission_count"
## [11] "mission_role"
## [12] "mission_year"
## [13] "mission"
## [14] "mission_vechicles_ascent"
## [15] "mission_vechicles_orbit"
## [16] "mission_vechicles_decent"
## [17] "duration"
## [18] "profile_lifetime_statistics_mission_duration"
## [19] "mission_durations_eva_duration"
## [20] "profile_lifetime_statistics_eva_duration"
For the EDA, I calculated the mean, median, max, min and standard deviation of “duration” variable, while grouping by gender.
# Finding mean, median, max and sd of duration and grouping by gender
eda <- astr |>
group_by(gender) |>
summarise(
count = n(),
mean_duration = mean(duration),
median_duration = median(duration),
max_duration = max(duration),
sd_duration = sd(duration)
)
eda
## # A tibble: 2 × 6
## gender count mean_duration median_duration max_duration sd_duration
## <fct> <int> <dbl> <dbl> <dbl> <dbl>
## 1 female 142 865. 266. 7372. 1566.
## 2 male 1128 1076. 260. 10505 1733.
For the plots, I created 2 of them. First, it is a boxplot comparing duration by gender, where it shows “male” have a high mission duration than “female”
# Creating a plot for comapring duration by gender
ggplot(astr, aes(x = gender, y = duration, fill = gender)) +
geom_boxplot() +
labs(
title = "Comparison of Space Mission Durations by Gender",
x = "Astronaut Gender",
y = "Mission Duration"
) +
theme_minimal()
Second, a simple histogram showing the distribution of mission duration also by gender. Here, males have very huge margin than the females. I changed the color from default to gender so it is easier to view the plot. However, the female variable is behind the male variable in pink color.
# Creating histogram that shows mission duration distribution by gender
ggplot(astr, aes(x = duration, fill = gender)) +
geom_histogram(bins = 30, alpha = 0.6, position = "identity") +
labs(
title = "Distribution of Mission Durations",
x = "Mission Duration",
y = "Count"
) +
theme_minimal()
I conducted a Welch Two Sample t-test which is independent to find out whether average space mission duration differ significantly between male and female.
# Running Welch two-sample t-test
test <- t.test(duration ~ gender, data = astr, var.equal = FALSE)
print(test)
##
## Welch Two Sample t-test
##
## data: duration by gender
## t = -1.4881, df = 187.26, p-value = 0.1384
## alternative hypothesis: true difference in means between group female and group male is not equal to 0
## 95 percent confidence interval:
## -488.74969 68.44537
## sample estimates:
## mean in group female mean in group male
## 865.3642 1075.5163
# Checking it by nationality
by_nation <- astr |>
mutate(nationality = profile_nationality) |>
group_by(nationality, gender) |>
summarise(
count = n(),
mean_duration = mean(duration),
median_duration = median(duration)) |>
arrange(desc(count))
## `summarise()` has regrouped the output.
## ℹ Summaries were computed grouped by nationality and gender.
## ℹ Output is grouped by nationality.
## ℹ Use `summarise(.groups = "drop_last")` to silence this message.
## ℹ Use `summarise(.by = c(nationality, gender))` for per-operation grouping
## (`?dplyr::dplyr_by`) instead.
head(by_nation)
## # A tibble: 6 × 5
## # Groups: nationality [5]
## nationality gender count mean_duration median_duration
## <chr> <fct> <int> <dbl> <dbl>
## 1 U.S. male 726 549. 240
## 2 U.S.S.R/Russia male 267 2536. 3002
## 3 U.S. female 124 856. 266.
## 4 Japan male 17 2100. 378.
## 5 France male 16 905. 332.
## 6 Germany male 16 1284. 259.
Here, we fail to reject the null hypothesis as the p-value (0.1384) is not less than 0.05. There is insufficient statistical evidence to conclude that average space mission duration differ significantly between male and female astronauts; the observed difference in sample averages is consistent with random variation rather than a systematic gender gap.