Qu'est ce que tu ajouteais au code suivant sur Rstudi : library(dplyr)
library(ggplot2)
library(corrgram)
library(corrplot
db <- read.csv(“2019.csv”)
view(db)
distinct(db. Region)
dbContinent<−NAview(db)dbContinent[which(dbRegiondbContinent[which(dbRegiondbContinent[which(dbRegiondbContinent[which(dbRegiondbContinent[which(dbRegiondbContinent[which(db$Region %in% c(“Latin America and Caribbean”))] <- “South America”
summary (db)
hp<- aggregate (db[,2 : 5], list (db$Continent). mean)
View (hp)
view (head(db,10))
view(tail(db,10))
ggplot(gp, aes(x=Group.A.y=Hapiness.Score, fill=Group.1)) + geom_bar(stat = “identity”) + ggtitle(“Hapiness Score of Continent”) + ylab(“Hapiness Score”) + xlab (“Continent”)
col<- sapply(db, is.numeric)
cor.data<- cor(db[,col])
#corrplot(cor.data,method=”square”, type = “upper”)
corrplot(cor.data,method=”number”, type = “upper”)
box <- ggplot(db, aes(x=Region, y=Hapiness.Score, color=”Region”))
box + geom_boxplot() + geom_jitter(aes(color=Country), size=1.0) +ggtitle(“Hapiness Score”) + coord_flip() + theme(legend.position = “none”)
#Regression technique for various parameters present in dataset
ggplot(db, aes(x=Continent, y=Hapiness.Score, color=Continent)) + geom_boxplot() + ggtitle (“Hapiness Score for Continents”)
ggplot(db, aes(x=Health..Life.Expectancy., y=Hapiness.Score)) + geom_point(aes(color=Region), size=3, alpha=0,8) + geom_smooth(aes(color=Continent, fill=Country), method = “lm”, fullrange=T) + facet_wrap(~Region) + them_bw() + ggtitle(“Scatter Plot for Life Expectancy”)
ggplot(db, aes(x=Economy..GDP.per.Capita., y=Hapiness.Score)) + geom_point(aes(color=Region), size=3, alpha=0,8) geom_smooth(aes(color=Continent, fill=Country), method = “lm”, fullrange=T) + facet_wrap(~Region) + them_bw() + ggtitle(“Scatter Plot for Economy”)
#ggplot(db, aes(x= Continent, y=Hapiness..Life.Expectancy;, color=Continent)) + geom_boxplot()
ggplot(db, aes(x= Freedom, y=Hapiness.Score)) + geom_point(aes(color=Region), size=3, alpha=0.8) + geom_smooth(aes(color=Continent, fill=Country), method = “lm”, fullrange=T) + facet_wrap(~Region) +theme_bw() + ggtitle(“Scatter Plot for Freedom”)
ggplot(db, aes(x= Family, y=Hapiness.Score)) + geom_point(aes(color=Region), size=3, alpha=0.8) + geom_smooth(aes(color=Continent, fill=Country), method = “lm”, fullrange=T) + facet_wrap(~Region) +theme_bw() + ggtitle(“Scatter plot for Family”)
#similarly
ggplot(db, aes(x=Trust.,Government.Corruption.. y=Hapiness.Score)) + geom_point(aes(color=Region), size=3, alpha=0,8) + geom_smooth(aes(color=Continent, fill=Country), method = “lm”, fullrange=T) + facet_wrap(~Region) + theme_bw() + ggtitle(“Scatter Plot for Trust on Government”)
#Hapiness Meter based on observation
dbHapinessMeter<−NAdbHapinessMeter [which(dbRegiondbHapinessMeter [which(dbHapinessMeter [which(db$Region %in% c(“Middle East and Northern Africa”,“Latin America and Caribbean”,”Eastern Asia”,”Southeastern Asia”,”Central and Eastern Europe”))]<- “Neutral”
#to load world map in our program
library(rworldmap)
d<- data.frame(country=dbCountry,value=dbEconomy..GDP.per.Capita.)
n<- joinCountryData2Map(d, joinCode = “NAME”, nameJoinColumn =”country”)
mapCountryData(n, nameColumnToPlot = “value”, mapTitle = “WorldMap for GDP 2015”, colourPalette = “terrain”)