library(dplyr)
## 
## 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(ggplot2)

data1 <- read.csv("C:\\Statistics\\nba.csv")
head(data1)
##       bbrID       Date  Tm Opp TRB AST STL BLK PTS GmSc  Season Playoffs Year
## 1 abdelal01 1993-03-16 BOS GSW  10   2   0   0  25 22.7 1992-93    false 1993
## 2 abdulma02 1991-04-02 DEN DAL   2   6   4   0  30 29.7 1990-91    false 1991
## 3 abdulta01 1998-04-19 SAC VAN   2   3   1   0  31 26.4 1997-98    false 1998
## 4 abdursh01 2001-11-23 ATL DET  12   5   2   1  50 46.0 2001-02    false 2002
## 5 abrinal01 2018-11-01 OKC CHO   2   0   0   0  25 17.1 2018-19    false 2019
## 6 achiupr01 2021-01-12 MIA PHI  13   3   0   1  17 16.9 2020-21    false 2021
##   GameIndex GmScMovingZ GmScMovingZTop2Delta      Date2 GmSc2 GmScMovingZ2
## 1       181        4.13                 0.24 1991-12-04  18.6         3.89
## 2        64        3.82                 0.64 1995-12-07  40.1         3.18
## 3        58        4.11                 1.67 1998-01-14  16.9         2.44
## 4       386        4.06                 0.84 2003-11-28  34.3         3.22
## 5       160        3.37                 0.18 2018-11-30  16.6         3.19
## 6         8        2.58                 0.05 2021-02-28  16.8         2.53
# Grouping the data by Team and summarizing points
group1 <- data1 %>%
  group_by(Tm) %>%
  summarise(mean_pts = mean(PTS, na.rm = TRUE))

# Grouping by Season and summarizing total rebounds
group2 <- data1 %>%
  group_by(Season) %>%
  summarise(mean_trb = mean(TRB, na.rm = TRUE))

# Grouping by Year and Playoffs status and summarizing assists
group3 <- data1 %>%
  group_by(Year, Playoffs) %>%
  summarise(mean_ast = mean(AST, na.rm = TRUE))
## `summarise()` has grouped output by 'Year'. You can override using the
## `.groups` argument.
# Visualization for Group 1 (Tm vs Points)
ggplot(group1, aes(x = Tm, y = mean_pts)) +
  geom_bar(stat = "identity") +
  theme_minimal() +
  labs(title = "Average Points by Team", x = "Tm", y = "Average Points")

Note that the echo = FALSE parameter was added to the code chunk to prevent printing of the R code that generated the plot.