```{r setup, include=FALSE} library(flexdashboard) library(tidyverse) library(ggplot2) library(dplyr) library(shiny)

netflix <- read_csv(“C:/Users/User/Documents/R/netflix_titles.csv”) head(netflix, 10)

#4  Display the Data Rows
```{r}
str(netflix)

5. 📊 Summary of the Dataset

{r} summary(netflix)

You’ll get statistics such as number of NAs, character counts, etc.

#6 Identify Missing Values {r} colSums(is.na(netflix)) #7 Data Visualization #Chart A-Bar chart ```{r} ggplot(netflix, aes(x = type)) + geom_bar(fill = “skyblue”) + labs(title = “Distribution of Movies vs TV Shows”, x = “Type”, y = “Count”)

#Chart B- Pie chart of content by rating:
```{r}
rating_count <- netflix %>% count(rating)
ggplot(rating_count, aes(x = "", y = n, fill = rating)) +
  geom_col() +
  coord_polar(theta = "y") +
  labs(title = "Content Ratings Distribution")

`

c. Histogram of release years:

```{r} ggplot(netflix, aes(x = release_year)) + geom_histogram(binwidth = 1, fill = “darkgreen”) + labs(title = “Netflix Releases Over the Years”, x = “Year”, y = “Count”)





-----------------------------------------------------------------------

### Chart D- Box Plot of Movie Duration by Rating

```{r}

ggplot(movies, aes(x = rating, y = duration_minutes)) +
  geom_boxplot(fill = "lightblue") +
  labs(title = "Movie Duration by Rating", x = "Rating", y = "Duration (Minutes)") +
  theme_minimal()


Chart E Box Plot of TV Show Seasons by Country (Top 5 Countries)

```{r} tv_shows <- netflix %>% filter(type == “TV Show”, !is.na(country)) %>% mutate(seasons = as.numeric(str_extract(duration, “\d+”))) %>% drop_na(seasons)

top_countries <- tv_shows %>% count(country, sort = TRUE) %>% top_n(5, n) %>% pull(country)

tv_top <- tv_shows %>% filter(country %in% top_countries)

ggplot(tv_top, aes(x = country, y = seasons)) + geom_boxplot(fill = “salmon”)+ labs(title = “Number of Seasons by Country”, x = “Country”, y = “Seasons”) + theme_minimal()

##Chat F-Scatter Plot of Release Year vs. Duration (Movies only)
```{r}
ggplot(movies, aes(x = release_year, y = duration_minutes)) +
  geom_point(alpha = 0.5, color = "purple") +
  labs(
    title = "Netflix Movies: Release Year vs Duration",
    x = "Release Year",
    y = "Duration (minutes)"
  ) +
  theme_minimal()

Chart G-Scatter plot-Prepare movie data with country and duration

{r} ggplot(movie_summary, aes(x = movie_count, y = avg_duration)) + geom_point(color = "darkred", alpha = 0.6) + labs( title = "Country-wise Netflix Movie Count vs. Average Duration", x = "Number of Movies", y = "Average Duration (minutes)" ) + theme_light()

8. Filtering: Show Content by Country

{r} india_shows<- netflix_data %>% filter(country == "India") head(india_shows) or count per country

```{r} netflix_data %>% count(country, sort = TRUE)

## 9. Modeling (Optional)

```{r}
yearly <- netflix %>% group_by(release_year) %>% summarise(count = n())
ggplot(yearly, aes(x = release_year, y = count)) +
  geom_line(color = "red") +
  labs(title = "Content Released Over Time")

#10.R Shiny for Interactive Visuals

```{r} ui <- fluidPage( titlePanel(“Netflix Dashboard”), sidebarLayout( sidebarPanel(selectInput(“rating”, “Choose a Rating:”, choices = unique(netflix$rating))), mainPanel(plotOutput(“histPlot”)) ) )

server <- function(input, output) { output\(histPlot <- renderPlot({ filtered <- netflix %>% filter(rating == input\)rating) ggplot(filtered, aes(x = release_year)) + geom_histogram(binwidth = 1, fill = “blue”) + labs(title = paste(“Releases with”, input$rating, “Rating”)) }) }

shinyApp(ui = ui, server = server) ```