library(ggplot2) #set working directory setwd("C:/Users/MOHANKRISHNA/Desktop/datascience") #Loading csv files data1 <- read.table(file="so.csv", sep = ",", header = TRUE, colClasses = c("factor","factor","numeric","numeric"), na.string = "NA") ggplot(data = data1, aes(x=Entity, y=SO2)) + geom_bar(stat = "identity")
ordered <- data1[order(data1$SO2),] ggplot(data = data1, aes(x=Entity, y=SO2)) + geom_bar(stat = "identity") + scale_x_discrete(limits=ordered$Entity)
Where did I go wrong? Why is the stat="identity" not working by showing the same values that are in the dataset? Why is scale_x_discrete not working by arranging the bars in increasing heights?
Here is the dataset
https://ourworldindata.org/air-pollution (Click the data button under the first chart you see. Thanks.)
I renamed the million tonnes as SO2.