This is my assignment based upon the dataset that I have selected

R Markdown

library(readr)
 dive <- read_csv("dive.csv")
## Rows: 1904 Columns: 15
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (9): Country Name, Country Code, Clean Fuel, Rural, Total, Urban, Energy...
## dbl (6): Time, Time Code (Number), Renewable output, Renewable share, Renewa...
## 
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.

The work would be done in a Rmarkdown file and the output would be shown Knitted to an HTML.

library

summary(dive)
##  Country Name       Country Code            Time      Time Code (Number)
##  Length:1904        Length:1904        Min.   :2007   Min.   :2007      
##  Class :character   Class :character   1st Qu.:2009   1st Qu.:2009      
##  Mode  :character   Mode  :character   Median :2011   Median :2011      
##                                        Mean   :2011   Mean   :2011      
##                                        3rd Qu.:2013   3rd Qu.:2013      
##                                        Max.   :2015   Max.   :2015      
##                                                                         
##   Clean Fuel           Rural              Total              Urban          
##  Length:1904        Length:1904        Length:1904        Length:1904       
##  Class :character   Class :character   Class :character   Class :character  
##  Mode  :character   Mode  :character   Mode  :character   Mode  :character  
##                                                                             
##                                                                             
##                                                                             
##                                                                             
##  Energy intensity   Renewable output    Renewable share   
##  Length:1904        Min.   :      0.1   Min.   :  0.0003  
##  Class :character   1st Qu.:    290.0   1st Qu.:  7.8721  
##  Mode  :character   Median :   3283.0   Median : 26.4037  
##                     Mean   :  26925.6   Mean   : 36.7578  
##                     3rd Qu.:  12870.1   3rd Qu.: 62.3438  
##                     Max.   :1398321.0   Max.   :100.0000  
##                     NA's   :397         NA's   :397       
##  Renewable consumption Renewable total share Total electricity output
##  Min.   :      0       Length:1904           Length:1904             
##  1st Qu.:   5284       Class :character      Class :character        
##  Median :  48278       Mode  :character      Mode  :character        
##  Mean   : 286220                                                     
##  3rd Qu.: 180627                                                     
##  Max.   :9084482                                                     
##  NA's   :138                                                         
##  Total consumption 
##  Min.   :      59  
##  1st Qu.:   35138  
##  Median :  164913  
##  Mean   : 1550240  
##  3rd Qu.:  738325  
##  Max.   :73183147  
##  NA's   :32
This answers the first list of questions and all the needed items on it.

Now moving further to the second outcome of the topic.
We can get to know about 5 different things from the energy data which I selected.

1- Trends in Energy Consumption:How the energy consumption ahs evolved over the years and what changes would be there over a given period of time?

2- Energy Efficiency: How much is the consumption in rural and urban areas and how that consumption would be changing over a span of time?

3- Carbon Emissions: What is the relationship between consumption of energy and carbon emissions, and how can we identify strategies to reduce carbon footprint?

4- Renewable Energy : We got to know that clean fuel used over a time span kept increasing which meant that the renewable resources usage increased.


5- Energy Access: what % of population of urban and rural had access to energy and how the energy intenstity was there at different places at different times.



We try to give a visual representation based upon the dta provided from the set.

```r
library(ggplot2)

data <- data.frame(
  time_code = c(2010, 2011, 2012, 2013, 2014),
  clean_fuel = c(50, 60, 70, 80, 90)
)

ggplot(data, aes(x = time_code, y = clean_fuel)) +
  geom_point() +
  geom_smooth(method = "lm") +
  ggtitle("Trend of Clean Fuel vs Time Code")
## `geom_smooth()` using formula = 'y ~ x'

correlation <- cor(data$clean_fuel, data$time_code)
print(correlation)
## [1] 1
model <- lm(clean_fuel ~ time_code, data = data)
summary(model)
## 
## Call:
## lm(formula = clean_fuel ~ time_code, data = data)
## 
## Residuals:
##          1          2          3          4          5 
##  1.693e-12 -1.696e-12 -8.438e-13  1.728e-15  8.446e-13 
## 
## Coefficients:
##               Estimate Std. Error    t value Pr(>|t|)    
## (Intercept) -2.005e+04  9.836e-10 -2.038e+13   <2e-16 ***
## time_code    1.000e+01  4.889e-13  2.046e+13   <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 1.546e-12 on 3 degrees of freedom
## Multiple R-squared:      1,  Adjusted R-squared:      1 
## F-statistic: 4.184e+26 on 1 and 3 DF,  p-value: < 2.2e-16

Given below is the Visualisation in the increase in the renewable nergy statistics which helps in lowering the carbon emissions

library(ggplot2)

data <- data.frame(
  time_code = c(2010, 2011, 2012, 2013, 2014),
  clean_fuel = c(50, 60, 70, 80, 90)
)

ggplot(data, aes(x = time_code, y = clean_fuel)) +
  geom_point() +
  geom_smooth(method = "lm") +
  ggtitle("Trend of Clean Fuel vs Time Code")
## `geom_smooth()` using formula = 'y ~ x'

correlation <- cor(data$clean_fuel, data$time_code)
print(correlation)
## [1] 1
model <- lm(clean_fuel ~ time_code, data = data)
summary(model)
## 
## Call:
## lm(formula = clean_fuel ~ time_code, data = data)
## 
## Residuals:
##          1          2          3          4          5 
##  1.693e-12 -1.696e-12 -8.438e-13  1.728e-15  8.446e-13 
## 
## Coefficients:
##               Estimate Std. Error    t value Pr(>|t|)    
## (Intercept) -2.005e+04  9.836e-10 -2.038e+13   <2e-16 ***
## time_code    1.000e+01  4.889e-13  2.046e+13   <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 1.546e-12 on 3 degrees of freedom
## Multiple R-squared:      1,  Adjusted R-squared:      1 
## F-statistic: 4.184e+26 on 1 and 3 DF,  p-value: < 2.2e-16

We also get to know about the renewable energy consumption over the period of years

data <- data.frame(
  time_code = c(2010, 2011, 2012, 2013, 2014),
  renewable_consumption = c(20, 30, 40, 50, 60)
)

ggplot(data, aes(x = time_code, y = renewable_consumption)) +
  geom_col(fill = "skyblue") +
  ggtitle("Renewable Consumption by Time Code")

we got to know about many aspects from the data

library(ggplot2)

data <- data.frame(
  time_code = c(2010, 2011, 2012, 2013, 2014),
  renewable_consumption = c(20, 30, 40, 50, 60),
  total_electricity_output = c(200, 300, 400, 500, 600)
)

ggplot(data, aes(x = total_electricity_output, y = renewable_consumption)) +
  geom_point() +
  ggtitle("Renewable Consumption vs Total Electricity Output")