Bubble Charts


# consolidate categories 2 and 3; 4 and 5; 8 and 9
bubdat$FinancesFullCostCat[bubdat$FinancesFullCostCat %in% c("2","3")] <- "0,0..0,1 M"
bubdat$FinancesFullCostCat[bubdat$FinancesFullCostCat %in% c("4","5")] <- "0,1..0,5 M"
bubdat$FinancesFullCostCat[bubdat$FinancesFullCostCat %in% c("6")] <- "0,5..2 M"
bubdat$FinancesFullCostCat[bubdat$FinancesFullCostCat %in% c("7")] <- "2 .. 5 M"
bubdat$FinancesFullCostCat[bubdat$FinancesFullCostCat %in% c("8", "9")] <- "More than 5 M"
bubdat$FinancesFullCostCat[bubdat$FinancesFullCostCat %in% c("98", "99")] <- NA #delete refused / NA cases 
#bubdat$FinancesFullCostCat[bubdat$FinancesFullCostCat %in% c("98", "99")] <- ".. refused/NA"

bubdat$OperationalStaffCat[bubdat$OperationalStaffCat =="1"] <- "1-10 people"
bubdat$OperationalStaffCat[bubdat$OperationalStaffCat  %in% c("2", "3")] <- "11-50 people"
bubdat$OperationalStaffCat[bubdat$OperationalStaffCat =="4"] <- "More than 50 people"
bubdat$OperationalStaffCat[bubdat$OperationalStaffCat %in% c("5", "6")] <- NA #delete refused / NA cases 
df_bubdat <- as.data.frame (table (bubdat[ ,c("FinancesFullCostCat", "OperationalStaffCat")]) )
# Calculate number of partnerships  --------
# 1st: table with frequencies per sector leader 
df_sector <- as.data.frame (table (bubdat[ ,c("FinancesFullCostCat", "OperationalStaffCat", "SectorOfLeader")]) )
df_bubdat [,c("Public","Privat", "Third","Multi")] <- 0 # adding columns for counting involved partnerships 


# loop
for (i in  1:15){
  df_bubdat [i,"Public"] <- sum (df_sector$Freq [df_sector$OperationalStaffCat == df_bubdat$OperationalStaffCat [i] & df_sector$FinancesFullCostCat == df_bubdat$FinancesFullCostCat [i] & df_sector$SectorOfLeader == 1])
  df_bubdat [i,"Privat"] <- sum (df_sector$Freq [df_sector$OperationalStaffCat == df_bubdat$OperationalStaffCat [i] & df_sector$FinancesFullCostCat == df_bubdat$FinancesFullCostCat [i] & df_sector$SectorOfLeader == 2])
  df_bubdat [i,"Third"] <- sum (df_sector$Freq [df_sector$OperationalStaffCat == df_bubdat$OperationalStaffCat [i] & df_sector$FinancesFullCostCat == df_bubdat$FinancesFullCostCat [i] & df_sector$SectorOfLeader == 3])
  df_bubdat [i,"Multi"] <- sum (df_sector$Freq [df_sector$OperationalStaffCat == df_bubdat$OperationalStaffCat [i] & df_sector$FinancesFullCostCat == df_bubdat$FinancesFullCostCat [i] & df_sector$SectorOfLeader == 4])
}