Explanation: The coder has tried to understand and visuallize the relation between Income and life expectancy. There is positive relation between these two variables. The more someone earns, the more number of years they can expect to live according to the graph.
library(tidyverse)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr 1.1.4 ✔ readr 2.1.5
## ✔ forcats 1.0.0 ✔ stringr 1.5.1
## ✔ ggplot2 3.4.4 ✔ tibble 3.2.1
## ✔ lubridate 1.9.3 ✔ tidyr 1.3.1
## ✔ purrr 1.0.2
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ 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(ggplot2)
library(dplyr)
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
library(ggthemes)
library(scales)
##
## Attaching package: 'scales'
##
## The following object is masked from 'package:purrr':
##
## discard
##
## The following object is masked from 'package:readr':
##
## col_factor
state1<-state.x77
colnames(state1)[4]<-"Life_Exp"
p<-data.frame(state1)
z<-ggplot(p, aes(x=Income, y=Life_Exp)) +
geom_point(col="steelblue", size=1) + # Set static color and size for points
geom_smooth(method="lm", col="firebrick") + # change the color of line
coord_cartesian(xlim=c(3000, 6500), ylim=c(65, 80)) +
labs(title="Income Vs Life Expectancy", y="Life Expectancy", x="Income")
ggplotly(z)
## `geom_smooth()` using formula = 'y ~ x'
Explanation: This graph tries to illustrates whether our earning capacity follow a pattern throughout our lives. There are two types of bars in the graph for every age of ages between 17-90, one that shows number of people who earn above 50K and one that earns below 50K per year. The bars in the graph indicate our earning capacity above 50K rises and peaks at 46 years of age and then declines. Earning capacity reaches at peak and declines with age. The data was taken from the following link https://www.kaggle.com/datasets/wenruliu/adult-income-dataset
library(tidyverse)
library(ggplot2)
library(dplyr)
library(plotly)
library(ggthemes)
library(scales)
library(gganimate)
data1<-read.csv("adult.csv")
p<-ggplot(data=data1)+
geom_bar(mapping=aes(x=age, fill= income)) +
labs(title="Income with Age", y="No of Participants", x="Age of every participant",
caption="Income earned people of different ages")
ggplotly(p)
Explanation: In the animation below, the analyst tried understand what happened to GDP of those European coutries where population increased with time. The animation shows increase in population slows down increase in GDP per capita.
library(gapminder)
View(gapminder)
library(gifski)
library(gganimate)
anime<-gapminder
gapminder %>%
filter(continent=="Europe") %>%
ggplot(aes(pop, gdpPercap, size=lifeExp, colour = country)) +
geom_point(alpha = 0.5, show.legend = TRUE) +
#scale_size(range = c(2,12)) +
# Here comes the gganimate specific bits
labs(title = 'Year: {frame_time}', x = 'Population', y = 'GDP per capita') +
transition_time(year) +
#shadow_wake(.1)+
ease_aes('linear')