library(ggplot2)
# Loading my dataset
data <- read.csv("player_data.csv")

# Identifying unclear columns.
unclear_column_1 <- "Player"  
unclear_column_2 <- "Colleges"
unclear_column_3 <- "numeric_date"

# Printing explanations for the columns from the documentation
cat("Explanation for", unclear_column_1, "column:", "This column contains the names of NBA players.", "\n")
## Explanation for Player column: This column contains the names of NBA players.
cat("Explanation for", unclear_column_2, "column:", "This column lists the colleges attended by players.", "\n")
## Explanation for Colleges column: This column lists the colleges attended by players.
cat("Explanation for", unclear_column_3, "column:", "This column represents numeric dates for when they started playing.", "\n")
## Explanation for numeric_date column: This column represents numeric dates for when they started playing.
# Numeric_Data column remains an unclear element in the dataset
unclear_element <- "Numeric_Date"  # 

# Explaination on why.
cat("The documentation did not provide sufficient information about", unclear_element, "and its context.")
## The documentation did not provide sufficient information about Numeric_Date and its context.
# Creating a visualization.
ggplot(data, aes(x = numeric_date, y = Ht)) +
  geom_point() +
  labs(title = "Player Height Over Time",
       x = "Numeric Date",
       y = "Height (in inches)") +
  # Highlight data points where numeric_date is outside the range of 1990 to 2000
  geom_point(data = data[!(data$numeric_date >= 1990 & data$numeric_date <= 2000), ], color = "red", size = 3) +
  # Annotate the issue at a specific x and y position
  annotate("text", x = 1995, y = 70, label = "Vague",
           color = "red", size = 5, vjust = -1)

# Analyze the dataset
# Check for missing values and empty strings in the 'Colleges' column
missing_values <- sum(is.na(data$Colleges) | data$Colleges == "")

# Discuss potential consequences and suggest mitigations
if (missing_values > 0) {
  cat("There are", missing_values, "missing values or empty strings in the 'Colleges' column.", "\n")
  cat("Consequence: Missing or empty college information can affect data analysis.", "\n")
  cat("Mitigation: Consider data imputation or cleaning as appropriate.", "\n")
} else {
  cat("No missing values or empty strings in the 'Colleges' column.", "\n")
}
## There are 351 missing values or empty strings in the 'Colleges' column. 
## Consequence: Missing or empty college information can affect data analysis. 
## Mitigation: Consider data imputation or cleaning as appropriate.