#install.packages("mapview")
#install.packages("terra")
library(terra)
## terra 1.7.46
library(mapview)
## The legacy packages maptools, rgdal, and rgeos, underpinning the sp package,
## which was just loaded, will retire in October 2023.
## Please refer to R-spatial evolution reports for details, especially
## https://r-spatial.org/r/2023/05/15/evolution4.html.
## It may be desirable to make the sf package available;
## package maintainers should consider adding sf to Suggests:.
## The sp package is now running under evolution status 2
## (status 2 uses the sf package in place of rgdal)
#install.packages("Rtools")
library(tidyverse)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr 1.1.2 ✔ readr 2.1.4
## ✔ forcats 1.0.0 ✔ stringr 1.5.0
## ✔ ggplot2 3.4.3 ✔ tibble 3.2.1
## ✔ lubridate 1.9.2 ✔ tidyr 1.3.0
## ✔ purrr 1.0.1
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ tidyr::extract() masks terra::extract()
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag() masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(readxl)
#install.packages("plotly")
library(plotly)
##
## Attaching package: 'plotly'
##
## The following object is masked from 'package:ggplot2':
##
## last_plot
##
## The following object is masked from 'package:stats':
##
## filter
##
## The following object is masked from 'package:graphics':
##
## layout
#install.packages("ggcleveland")
library(ggcleveland)
library(GGally)
## Registered S3 method overwritten by 'GGally':
## method from
## +.gg ggplot2
##
## Attaching package: 'GGally'
##
## The following object is masked from 'package:terra':
##
## wrap
#install.packages("devtools")
library(devtools)
## Loading required package: usethis
library(mapview)
data= read.csv("global-data-on-sustainable-energy.csv")
data
df= na.omit(data)
df
df
mapview(df, xcol = "Longitude", ycol = "Latitude" ,zcol = c("Access.to.electricity....of.population.", "Access.to.clean.fuels.for.cooking"), crs = 4269, grid = FALSE)
df
library(plotly)
library(ggplot2)
p<- df%>%
ggplot(aes(x=gdp_per_capita, y=Renewable.energy.share.in.the.total.final.energy.consumption....
, size = Density.n.P.Km2.
, color = Entity,frame = Year)) +
labs(x="GDP per Capita", y = "Renewable Energy Share",
caption = "(GDP vs. Renewable Energy Share)",
color = 'Entity',size = "Co2 Emissions by Country") +
ylim(30,100) +
geom_point(aes(text=Entity))
## Warning in geom_point(aes(text = Entity)): Ignoring unknown aesthetics: text
ggplotly(p)
## Warning: Using size for a discrete variable is not advised.
## Warning in p$x$data[firstFrame] <- p$x$frames[[1]]$data: number of items to
## replace is not a multiple of replacement length