Dataset Description

About the dataset

'data.frame':   398 obs. of  30 variables:
 $ Sector                             : chr  "Rural" "Urban" "Rural+Urban" "Rural" ...
 $ Year                               : num  2013 2013 2013 2013 2013 ...
 $ Month                              : chr  "January" "January" "January" "February" ...
 $ Cereals.and.products               : num  108 110 108 109 113 ...
 $ Meat.and.fish                      : num  106 109 107 109 113 ...
 $ Egg                                : num  108 113 110 110 117 ...
 $ Milk.and.products                  : num  105 104 104 105 104 ...
 $ Oils.and.fats                      : num  106 103 105 107 104 ...
 $ Fruits                             : num  104 102 103 104 103 ...
 $ Vegetables                         : num  102 103 102 102 105 ...
 $ Pulses.and.products                : num  106 106 106 106 104 ...
 $ Sugar.and.Confectionery            : num  107 105 106 106 104 ...
 $ Spices                             : num  103 102 103 103 102 ...
 $ Non.alcoholic.beverages            : num  105 105 105 105 106 ...
 $ Prepared.meals..snacks..sweets.etc.: num  107 108 107 108 109 ...
 $ Food.and.beverages                 : num  106 106 106 106 107 ...
 $ Pan..tobacco.and.intoxicants       : num  105 105 105 106 106 ...
 $ Clothing                           : num  106 106 106 107 107 ...
 $ Footwear                           : num  106 105 106 106 106 ...
 $ Clothing.and.footwear              : num  106 106 106 107 106 ...
 $ Housing                            : chr  NA "100.3" "100.3" NA ...
 $ Fuel.and.light                     : num  106 105 106 106 106 ...
 $ Household.goods.and.services       : num  105 105 105 105 105 ...
 $ Health                             : num  104 104 104 104 105 ...
 $ Transport.and.communication        : num  103 103 103 104 104 ...
 $ Recreation.and.amusement           : num  103 103 103 104 103 ...
 $ Education                          : num  104 104 104 104 104 ...
 $ Personal.care.and.effects          : num  105 104 104 105 104 ...
 $ Miscellaneous                      : num  104 104 104 104 104 ...
 $ General.index                      : num  105 104 105 106 105 ...

Summary of the Dataset

    Sector               Year         Month           Cereals.and.products
 Length:398         Min.   :2013   Length:398         Min.   :107.5       
 Class :character   1st Qu.:2015   Class :character   1st Qu.:124.7       
 Mode  :character   Median :2018   Mode  :character   Median :136.8       
                    Mean   :2018                      Mean   :139.7       
                    3rd Qu.:2021                      3rd Qu.:148.2       
                    Max.   :2024                      Max.   :188.6       
                                                      NA's   :3           
 Meat.and.fish        Egg        Milk.and.products Oils.and.fats  
 Min.   :106.3   Min.   :102.7   Min.   :103.6     Min.   :101.1  
 1st Qu.:131.3   1st Qu.:123.3   1st Qu.:128.8     1st Qu.:111.2  
 Median :146.5   Median :137.4   Median :141.7     Median :121.1  
 Mean   :160.3   Mean   :144.0   Mean   :143.0     Mean   :134.0  
 3rd Qu.:198.6   3rd Qu.:168.8   3rd Qu.:156.1     3rd Qu.:159.1  
 Max.   :226.6   Max.   :206.1   Max.   :183.2     Max.   :209.9  
 NA's   :6       NA's   :3       NA's   :3         NA's   :3      
     Fruits        Vegetables    Pulses.and.products Sugar.and.Confectionery
 Min.   :102.3   Min.   :101.4   Min.   :103.5       Min.   : 85.3          
 1st Qu.:131.1   1st Qu.:136.7   1st Qu.:121.0       1st Qu.:104.0          
 Median :142.8   Median :155.4   Median :142.6       Median :113.8          
 Mean   :143.2   Mean   :159.6   Mean   :145.1       Mean   :112.0          
 3rd Qu.:155.6   3rd Qu.:177.6   3rd Qu.:165.3       3rd Qu.:119.8          
 Max.   :186.7   Max.   :295.3   Max.   :210.1       Max.   :131.4          
 NA's   :3       NA's   :3       NA's   :3           NA's   :3              
     Spices      Non.alcoholic.beverages Prepared.meals..snacks..sweets.etc.
 Min.   :101.8   Min.   :104.8           Min.   :106.7                      
 1st Qu.:129.7   1st Qu.:120.7           1st Qu.:132.7                      
 Median :140.2   Median :130.2           Median :151.8                      
 Mean   :150.7   Mean   :136.8           Mean   :152.3                      
 3rd Qu.:165.5   3rd Qu.:156.3           3rd Qu.:171.2                      
 Max.   :249.8   Max.   :182.3           Max.   :204.0                      
 NA's   :3       NA's   :3               NA's   :6                          
 Food.and.beverages Pan..tobacco.and.intoxicants    Clothing    
 Min.   :105.5      Min.   :105.1                Min.   :105.9  
 1st Qu.:130.3      1st Qu.:132.4                1st Qu.:126.8  
 Median :139.6      Median :157.9                Median :144.8  
 Mean   :145.7      Mean   :158.6                Mean   :145.7  
 3rd Qu.:163.9      3rd Qu.:190.8                3rd Qu.:159.8  
 Max.   :199.4      Max.   :209.5                Max.   :195.4  
 NA's   :3          NA's   :6                    NA's   :6      
    Footwear     Clothing.and.footwear   Housing          Fuel.and.light 
 Min.   :105.0   Min.   :105.8         Length:398         Min.   :105.4  
 1st Qu.:121.6   1st Qu.:126.1         Class :character   1st Qu.:118.2  
 Median :135.6   Median :143.2         Mode  :character   Median :136.4  
 Mean   :138.9   Mean   :144.7                            Mean   :139.5  
 3rd Qu.:150.4   3rd Qu.:158.3                            3rd Qu.:156.9  
 Max.   :190.9   Max.   :194.8                            Max.   :187.4  
 NA's   :6       NA's   :6                                NA's   :3      
 Household.goods.and.services     Health      Transport.and.communication
 Min.   :104.8                Min.   :104.0   Min.   :103.2              
 1st Qu.:122.0                1st Qu.:119.6   1st Qu.:112.0              
 Median :137.3                Median :136.2   Median :121.1              
 Mean   :139.4                Mean   :141.8   Mean   :129.8              
 3rd Qu.:154.4                3rd Qu.:163.2   3rd Qu.:150.4              
 Max.   :183.3                Max.   :193.8   Max.   :172.2              
 NA's   :6                    NA's   :3       NA's   :6                  
 Recreation.and.amusement   Education     Personal.care.and.effects
 Min.   :102.9            Min.   :103.5   Min.   :102.1            
 1st Qu.:118.1            1st Qu.:125.7   1st Qu.:113.3            
 Median :132.4            Median :143.8   Median :129.6            
 Mean   :136.5            Mean   :143.8   Mean   :136.9            
 3rd Qu.:155.1            3rd Qu.:161.8   3rd Qu.:158.9            
 Max.   :177.4            Max.   :186.0   Max.   :190.1            
 NA's   :6                NA's   :6       NA's   :6                
 Miscellaneous   General.index  
 Min.   :103.7   Min.   :104.0  
 1st Qu.:117.2   1st Qu.:124.2  
 Median :132.2   Median :138.6  
 Mean   :137.1   Mean   :142.6  
 3rd Qu.:156.8   3rd Qu.:160.8  
 Max.   :183.8   Max.   :188.2  
 NA's   :6       NA's   :6      

Univariat Analysis

Education CPI for Rural and Urban (2023)

Year-over-Year Inflation Percentage

CPI Growth Across Sectors

Vegetable CPI: Rural vs Urban Comparison

Education CPI: Rural vs Urban Comparison

Box Plot of CPI Growth: Rural vs Urban

Education CPI vs Health CPI (2023)

---
title: "CPI Data Analysis"
output: 
  flexdashboard::flex_dashboard:
    orientation: rows
    vertical_layout: scroll
    theme: journal
    social: menu
    source_code: embed
---


```{r setup, include=FALSE}
library(flexdashboard)
library(ggplot2)
library(dplyr)
library(shiny)
data <- read.csv("datafile.csv")
data$Year <- as.numeric(data$Year)
```

## Dataset Description {.tabset}

### About the dataset
```{r}
str(data)
```

### Summary of the Dataset
```{r}
summary(data)
```

## Univariat Analysis {.tabset}
```{r}

```
### Education CPI for Rural and Urban (2023)
```{r}
data$Year <- as.numeric(data$Year)
data$Education <- as.numeric(data$Education)
data$Health <- as.numeric(data$Health)
data$Vegetables <- as.numeric(data$Vegetables)
data$General.index <- as.numeric(data$General.index)

filtered_data_2023 <- data %>%
  filter(Year == 2023 & Sector %in% c("Rural", "Urban"))

ggplot(filtered_data_2023, aes(x = Education, fill = Sector)) +
  geom_histogram(binwidth = 5, alpha = 0.7, position = 'dodge') +
  ggtitle(" Education CPI for Rural and Urban (2023)") +
  xlab("CPI for Education") +
  ylab("Count") +
  theme_minimal()
```

### Year-over-Year Inflation Percentage
```{r}
inflation_data <- data %>%
  group_by(Year) %>%
  summarise(Average_CPI = mean(General.index, na.rm = TRUE)) %>%
  mutate(Percentage_Increase = (Average_CPI - lag(Average_CPI)) / lag(Average_CPI) * 100)

ggplot(inflation_data, aes(x = Year, y = Percentage_Increase)) +
  geom_line(color = "blue") +
  ggtitle("Year-over-Year Inflation Percentage") +
  xlab("Year") +
  ylab("Inflation Percentage")
```

### CPI Growth Across Sectors
```{r}

sector_growth <- data %>%
  group_by(Year, Sector) %>%
  summarise(Average_CPI = mean(General.index, na.rm = TRUE)) %>%
  arrange(Year)

ggplot(sector_growth, aes(x = Year, y = Average_CPI, color = Sector)) +
  geom_line() +
  ggtitle("CPI Growth Across Sectors") +
  xlab("Year") +
  ylab("CPI Index")
```

### Vegetable CPI: Rural vs Urban Comparison
```{r}
veg_data <- data %>%
  filter(Sector %in% c("Rural", "Urban")) %>%
  group_by(Year, Sector) %>%
  summarise(Average_Vegetable_CPI = mean(Vegetables, na.rm = TRUE))

ggplot(veg_data, aes(x = Year, y = Average_Vegetable_CPI, color = Sector)) +
  geom_line() +
  ggtitle("Vegetable CPI: Rural vs Urban Comparison") +
  xlab("Year") +
  ylab("Vegetable CPI")
```

### Education CPI: Rural vs Urban Comparison
```{r}

edu_data <- data %>%
  filter(Sector %in% c("Rural", "Urban")) %>%
  group_by(Year, Sector) %>%
  summarise(Average_Education_CPI = mean(Education, na.rm = TRUE))

ggplot(edu_data, aes(x = Year, y = Average_Education_CPI, color = Sector)) +
  geom_line() +
  ggtitle("Education CPI: Rural vs Urban Comparison") +
  xlab("Year") +
  ylab("Education CPI")
```

### Box Plot of CPI Growth: Rural vs Urban
```{r}
ggplot(data, aes(x = Sector, y = General.index, fill = Sector)) +
  geom_boxplot() +
  ggtitle("Box Plot of CPI Growth: Rural vs Urban") +
  xlab("Sector") +
  ylab("CPI Index")

```

### Education CPI vs Health CPI (2023)
```{r}
# Scatter Plot for Education CPI vs Health CPI
ggplot(filtered_data_2023, aes(x = Education, y = Health, color = Sector)) +
  geom_point(size = 3, alpha = 0.7) +
  ggtitle(" Education CPI vs Health CPI (2023)") +
  xlab("CPI for Education") +
  ylab("CPI for Health") +
  theme_minimal() +
  theme(legend.position = "top")


```