rm(list = ls())
## Q : 1
world.data = read.csv(file.choose())
names(world.data)
##  [1] "country"          "colony"           "confidence"       "decentralization"
##  [5] "dem_other"        "dem_other5"       "democ_regime"     "district_size3"  
##  [9] "durable"          "effectiveness"    "enpp_3"           "eu"              
## [13] "fhrate04_rev"     "fhrate08_rev"     "frac_eth"         "frac_eth3"       
## [17] "free_business"    "free_corrupt"     "free_finance"     "free_fiscal"     
## [21] "free_govspend"    "free_invest"      "free_labor"       "free_monetary"   
## [25] "free_overall"     "free_property"    "free_trade"       "gdp08"           
## [29] "gdp_10_thou"      "gdp_cap2"         "gdp_cap3"         "gdppcap08"       
## [33] "gender_equal3"    "gini04"           "gini08"           "hi_gdp"          
## [37] "indy"             "oecd"             "old2006"          "old2003"         
## [41] "pmat12_3"         "pop03"            "pop08"            "pop08_3"         
## [45] "popcat3"          "pr_sys"           "protact3"         "regime_type3"    
## [49] "region"           "sources"          "typerel"          "unions"          
## [53] "urban03"          "urban06"          "vi_rel3"          "votevap00s"      
## [57] "women05"          "women09"          "womyear"          "womyear2"        
## [61] "yng2003"          "young06"
sum(is.na(world.data))
## [1] 1244

Q : 2

library(plyr)
## Warning: package 'plyr' was built under R version 4.0.5
ft.oecd = as.data.frame(table(world.data$oecd))
Percentage = (ft.oecd$Freq/191)*100
Percentage
## [1] 84.29319 15.70681
ft.oecd = cbind(ft.oecd,Percentage)
ft.oecd

Q: 3

A-Accourding to the above frequency table we can see that 30 countries are OECD member. B- 161 countries are not the member of OECD. C- 15.7068% Countries are member of OECD. D- 84.2931% are not member of OECD. ## Q: 4

library(ggplot2)
## Warning: package 'ggplot2' was built under R version 4.0.5
library(dplyr)
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:plyr':
## 
##     arrange, count, desc, failwith, id, mutate, rename, summarise,
##     summarize
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
world.data %>% ggplot(aes(x=oecd, fill = oecd)) +
  geom_bar() +
  labs(title = "OECD countries membership Bar chart",  x = ' OECD Membership' , y = 'Number of countries' ) +
  theme_classic()

## Q: 5 Following are three countries that are coded as OECD member states 1.Australia 2.Austria 3.Belgium Non - democratic countries are following 1.Afghanistan 2.Jordan 3.Kazakhstan ## Q: 6

gdp_10_thou = world.data$gdp_10_thou
gdp_10_thou=na.omit(gdp_10_thou)
summary(gdp_10_thou)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##  0.0090  0.0503  0.1897  0.6018  0.6320  4.7354

Standard deviation

sd(gdp_10_thou)
## [1] 0.9433982

Q:7

  1. positively skewed (skewed to the right). ## Q: 8
hist(gdp_10_thou, main = "GDP Per Capita",
     xlab = "Per capita GDP (in 10,000 US dollars",
     ylab = "Number of countries",
     border = "blue",
     col = "green",
     las=1,breaks = 5)

## Q: 9

library(dplyr)
world.data%>% group_by(country) %>%filter(gdp_10_thou>"4")

Q: 10

S.E =sd(gdp_10_thou)/sqrt(length(gdp_10_thou))
S.E
## [1] 0.07091015

Q: 11

mean=0.1618
Stddev=0.9433
SE= 0.0709
Lower_bound= mean - 1.96*(SE)
Lower_bound
## [1] 0.022836
Uper_bound = mean + 1.96*SE
Uper_bound
## [1] 0.300764

Q:12

ggplot(world.data, aes(x = world.data$gdp_10_thou))+
  geom_histogram(fill = "white",colour= "black",bins = 5)
## Warning: Use of `world.data$gdp_10_thou` is discouraged. Use `gdp_10_thou`
## instead.
## Warning: Removed 14 rows containing non-finite values (stat_bin).

#

democ_regime= world.data$democ_regime
democ_regime= factor(democ_regime,levels = c("Yes","No"),labels = c("Democracy","Autocracy"))
dem.dum= as.data.frame(democ_regime)
dem.dum
ggplot(world.data, aes(x = gdp_10_thou))+
  geom_histogram(fill = "white",colour= "black")+
  facet_grid(democ_regime) 
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## Warning: Removed 14 rows containing non-finite values (stat_bin).

## Q15 For this question there is an issue due to the length difference in two variables. When we make new variable dem.dum and remove missing values it contains 189 observations and other variable gdp_10_thou consist of 177 observations. Therefore I am unable to find mean and confidence interval that are mention in this question.