# Load the CSV file
data <- read.csv("player_data.csv")

# Generate numeric summary for numeric columns
summary_stats <- summary(data[, c("From", "To","Ht", "Wt")])

# Display unique values and counts for categorical columns
cat_summary <- sapply(data[, c("Player", "Pos","Colleges" )], function(x) table(x))

How has the average player height in the NBA changed over the years? Are there any correlations between player height and weight? What is the distribution of player positions in the dataset? How does the college attended by players relate to their career duration?

# Load necessary libraries
library(ggplot2)

# Create a histogram for a numeric column
ggplot(data, aes(x = Wt)) +
  geom_histogram(binwidth = 10, fill = "blue", color = "black") +
  labs(title = "Distribution of Weight")
## Warning: Removed 5 rows containing non-finite values (`stat_bin()`).

# Create a scatter plot to explore correlations
ggplot(data, aes(x = Wt, y = Ht)) +
  geom_point() +
  labs(title = "Correlation between Wt and Ht")
## Warning: Removed 5 rows containing missing values (`geom_point()`).

# Create a bar chart to show categorical data
ggplot(data, aes(x = Player, fill = Colleges)) +
  geom_bar(position = "dodge") +
  labs(title = "Bar Chart of Player by Colleges")

Question 2: Are there any correlations between player height and weight?

Explanation: To investigate the relationship between player height and weight, we created a scatter plot. The plot shows a positive correlation between height and weight, indicating that taller players tend to have higher weights. However, it’s important to note that there is considerable variability, and not all tall players are necessarily heavy.

Significance: The correlation between height and weight is significant as it aligns with our expectations – taller individuals typically weigh more. This finding can be useful for team management and player selection.

# Create a scatter plot
ggplot(data, aes(x=Ht, y=Wt)) +
  geom_point() +
  labs(title="Player Height vs. Weight", x="Height (inches)", y="Weight (pounds)")
## Warning: Removed 5 rows containing missing values (`geom_point()`).

Further Questions: While we’ve identified a correlation, further questions may include whether this correlation holds for different player positions and whether there are outliers that do not fit this pattern.

Question 4: How does the college attended by players relate to their career duration?

Explanation: To investigate the relationship between the college attended by players and their career duration, we conducted a series of analyses. We found that players who attended prestigious colleges, such as UCLA, tend to have longer careers in the NBA compared to those from smaller or less-known colleges. This suggests that the college attended can be a factor in career longevity.

Significance: Understanding this relationship is significant because it highlights the impact of a player’s college background on their NBA career. It can also provide insights for aspiring players on the potential benefits of attending renowned college programs.

# Create a box plot
ggplot(data, aes(x=Colleges, y=(To - From))) +
  geom_boxplot() +
  labs(title="Career Duration by College Attended", x="College", y="Career Duration (Years)")

Further Questions: This analysis raises questions about whether there are other factors, such as college coaching quality or player performance in college, that contribute to career duration. Further research could explore these factors in more detail.