[This article was first published on Heteroscedasticity, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
< section id="bonds-worth-121-billion-purchase-between-apr-2019-and-jan-2024" class="level2">
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
Bonds worth ₹ 121 Billion purchase between Apr 2019 and Jan 2024
Data was downloaded from dataful. Rows without reference number or with status Expired
are not considered in this analysis. Hence, there may be a variation between the numbers.of excluded data is available below
< details class="code-fold">
< summary>Code
< section id="b-of-money-went-to-5-parties.-91-111-b-of-money-came-from-5-states" class="level4">
highchart() |> hc_chart(type = "sankey", inverted = FALSE) |> hc_add_series( data = list_parse(sankey.dat), nodes = list_parse(nodes), name = "Flow", type = "sankey", nodeWidth = 20, linkOpacity = 0.5, # Make links semi-transparent states = list( hover = list( linkOpacity = 0.8 # Increase opacity on hover ) ) ) |> hc_plotOptions( sankey = list( nodePadding = 3, curveFactor = 0.6, colors = c("#1f77b4", "#ff7f0e", "#2ca02c"), # Colors for nodes linkColor = "#d3d3d3" # Default link color (can be rgba for transparency) ) ) |> hc_title( text = "Flow of Electoral Bonds", align = "left", style = list( textDecoration = "underline", color = "#333333", Weight = "bold" ) ) |> hc_subtitle( text = "Electoral bond encashment between Apr 16, 2019 and Jan 24, 2024" ) |> hc_tooltip( formatter = JS(" function() { var amount = this.point.weight; // Check if it's a node (will have no 'weight' property) if (typeof amount === 'undefined') { return '<b>' + this.point.name + '</b>'; } // For links if (amount >= 1000000000) { return '<b>' + this.point.from + '</b> to <b>' + this.point.to + '</b>: ₹' + (amount/1000000000).toFixed(2) + 'B'; } else { return '<b>' + this.point.from + '</b> to <b>' + this.point.to + '</b>: ₹' + (amount/1000000).toFixed(2) + 'M'; } } ") ) |> hc_credits( enabled = TRUE, text = "Heteroscedasticity", href = "https://asitavsen.com", style = list(Size = "12px") ) |> hc_add_theme(custom_theme) |> hc_exporting( enabled = TRUE, filename = "ElectoralBondFlow" )
86 % (₹ 105 B) of money went to 5 parties. 91 % (₹ 111 B) of money came from 5 states
< details class="code-fold"> < summary>Code##| fig-width: 10 # Plot amount distribution by political party plot_hc_pie_chart( amount_by_party, xval = "standardised_political_party_name", yval = "total_amount", series_name = "Amount", theme = custom_theme, title_text = "Amount by Political Party", subtitle_text = "Electoral bond encashment between Apr 16, 2019 and Jan 24, 2024", output_filename = "AmountByPoliticalParty" ) # Plot amount distribution by state plot_hc_pie_chart( amount_by_state, xval = "issue_branch_state", yval = "total_amount", series_name = "Amount", theme = custom_theme, title_text = "Amount by State", output_filename = "AmountByState", subtitle_text = "Electoral bond encashment between Apr 16, 2019 and Jan 24, 2024" ) # Create and plot top purchasers chart plot_hc_pie_chart( rbind( data.comb[, .(total_amount = sum(amount)), by = .(standardised_purchaser_name) ][order(-total_amount)][1:20], data.table( standardised_purchaser_name = "Others", total_amount = data.comb[, .(total_amount = sum(amount)), by = .(standardised_purchaser_name) ][order(-total_amount)][21:.N, sum(total_amount)] ) ), xval = "standardised_purchaser_name", yval = "total_amount", series_name = "Amount", theme = custom_theme, title_text = "Amount by Purchaser", output_filename = "AmountByPurchaser", subtitle_text = "Electoral bond encashment between Apr 16, 2019 and Jan 24, 2024" )
>70% of Purchasers are organizations; contributed 96% amount
< details class="code-fold">
< summary>Code
# Calculate summary statistics total_contribution <- sum(data.comb$amount) total_purchasers <- uniqueN(data.comb$standardised_purchaser_name) # Calculate organization vs individual statistics org.ind <- data.comb[, .( total_amount = sum(amount), contribution_percent = round(100 * sum(amount) / total_contribution, 2), purchasers = uniqueN(standardised_purchaser_name), transactions = .N, avg_contribution = sum(amount) / uniqueN(standardised_purchaser_name), avg_transaction_val = sum(amount) / .N ), by = .(organisation_or_individual)] org.ind.count <- unique( data.comb[, .(organisation_or_individual, standardised_purchaser_name)] )[, .( N = .N, count_percent = round(100 * .N / total_purchasers, 2) ), by = organisation_or_individual] highchart() |> hc_add_series( org.ind, "column", hcaes(x = organisation_or_individual, y = total_amount), name = "Purchase Amount", dataLabels = list(enabled = TRUE, align = "right") ) |> hc_add_series( org.ind, "pie", hcaes(name = organisation_or_individual, y = contribution_percent), name = "Share of Purchase", dataLabels = list(enabled = TRUE, align = "right") ) |> hc_plotOptions( series = list(showInLegend = FALSE, colorByPoint = TRUE), pie = list( center = c("70%", "30%"), size = 120, dataLabels = list(enabled = FALSE) ) ) |> hc_yAxis(title = list(text = "Purchase Amount (M)")) |> hc_xAxis(categories = org.ind$organisation_or_individual) |> hc_tooltip( shared = FALSE, useHTML = TRUE, formatter = JS(" function() { if (this.series.type === 'column') { return '<b>' + this.point.name + '</b>: ₹' + (this.y / 1000000).toFixed(2) + ' M'; } else if (this.series.type === 'pie') { return '<b>' + this.point.name + '</b>: ' + this.y + '%'; } } ") ) |> hc_title( text = "Purchase amount by Individuals and Organization", align = "left", style = list( textDecoration = "underline", color = "#333333", Weight = "bold" ) ) |> hc_subtitle( text = "Electoral bond encashment between Apr 16, 2019 and Jan 24, 2024" ) |> hc_credits( enabled = TRUE, text = "Heteroscedasticity", href = "https://blog.asitavsen.com", style = list(Size = "12px") ) |> hc_add_theme(custom_theme) |> hc_exporting(enabled = TRUE, filename = "OrgvsIndAmt")
< details class="code-fold">
< summary>Code
# Plot purchaser count distribution highchart() |> hc_add_series( org.ind.count, "column", hcaes(x = organisation_or_individual, y = N), name = "Number of Purchasers", dataLabels = list(enabled = TRUE, align = "right") ) |> hc_add_series( org.ind.count, "pie", hcaes(name = organisation_or_individual, y = count_percent), name = "Share of Purchasers", dataLabels = list(enabled = TRUE, align = "right") ) |> hc_plotOptions( series = list(showInLegend = FALSE, colorByPoint = TRUE), pie = list( center = c("70%", "30%"), size = 120, dataLabels = list(enabled = FALSE) ) ) |> hc_yAxis(title = list(text = "Number of Purchasers")) |> hc_xAxis(categories = org.ind.count$organisation_or_individual) |> hc_tooltip( shared = FALSE, useHTML = TRUE, formatter = JS(" function() { if (this.series.type === 'column') { return '<b>' + this.point.name + '</b>: ' + this.y + ' purchasers'; } else if (this.series.type === 'pie') { return '<b>' + this.point.name + '</b>: ' + this.y + '%'; } } ") ) |> hc_title( text = "#Organizational vs Individual purchasers", align = "left", style = list( textDecoration = "underline", color = "#333333", Weight = "bold" ) ) |> hc_subtitle( text = "Electoral bond encashment between Apr 16, 2019 and Jan 24, 2024" ) |> hc_credits( enabled = TRUE, text = "Heteroscedasticity", href = "https://blog.asitavsen.com", style = list(Size = "12px") ) |> hc_add_theme(custom_theme) |> hc_exporting(enabled = TRUE, filename = "Purchasers")
Individuals
Highest encashment by BJP but INC had more purchasers (Individuals). Biggest purchase made by MS S N Mohanty (Encashed by Biju Janta Dal) followed by Lakshmi Niwas Mittal (Encashed by BJP). Most purchases (value) were made in Maharashtra.
< details class="code-fold">
< summary>Code
# Calculate individual party contributions and statistics ind_party <- data.comb[ organisation_or_individual == "Individual", .( total_amount = sum(amount), count = .N, per_count = .N / sum(data.comb[organisation_or_individual == "Individual", .N]) ), by = standardised_political_party_name ][order(-total_amount)] # Create combined column and pie chart highchart() |> hc_add_series( ind_party, "column", hcaes(x = standardised_political_party_name, y = total_amount), name = "Amount" ) |> hc_add_series( ind_party, "pie", hcaes(name = standardised_political_party_name, y = count), name = "#Purchasers", dataLabels = list(enabled = FALSE) ) |> hc_plotOptions( series = list( showInLegend = FALSE, colorByPoint = TRUE ), pie = list( center = c("75%", "25%"), size = 120, innerSize = "75%", dataLabels = list(enabled = FALSE) ) ) |> hc_yAxis( title = list(text = "Total Purchase (in millions)"), labels = list( formatter = JS("function() { return (this.value / 1000000) + ' M'; }") ) ) |> hc_xAxis(categories = ind_party$standardised_political_party_name) |> hc_tooltip( shared = FALSE, useHTML = TRUE, formatter = JS(" function() { if (this.series.type === 'column') { return '<b>' + this.point.name + '</b>: ₹' + (this.y / 1000000).toFixed(2) + ' M'; } else if (this.series.type === 'pie') { return '<b>' + this.point.name + '</b>: ' + this.y + ' contributors'; } } ") ) |> hc_title( text = "Electoral Bond Purchases by Organizations (Amount and Purchasers)", align = "left", style = list( textDecoration = "underline", color = "#333333", Weight = "bold" ) ) |> hc_subtitle( text = "Electoral bond encashment between Apr 16, 2019 and Jan 24, 2024" ) |> hc_credits( enabled = TRUE, text = "Heteroscedasticity", href = "https://asitavsen.com", style = list(Size = "12px") ) |> hc_add_theme(custom_theme) |> hc_exporting( enabled = TRUE, filename = "Individuals" )
< details class="code-fold">
< summary>Code
# Calculate individual contributions and statistics by party ind_amount_count_by_party <- data.comb[ organisation_or_individual == "Individual", .( total_amount = sum(amount), count = uniqueN(standardised_purchaser_name), avg = sum(amount) / uniqueN(standardised_purchaser_name) ), by = standardised_political_party_name ][order(-avg)] # Calculate individual contributions by party and purchaser party_ind_top <- data.comb[ organisation_or_individual == "Individual", .(total_amount = sum(amount)), by = .(standardised_political_party_name, standardised_purchaser_name) ][, standardised_political_party_name := fct_other( standardised_political_party_name, keep = c( "Indian National Congress", "Bharatiya Janata Party", "All India Trinamool Congress", "Bharat Rashtra Samithi", "Biju Janata Dal" ) )] # Get party order by total amount party_order <- party_ind_top[ , .(range_diff = sum(total_amount)), by = standardised_political_party_name ][order(-range_diff), standardised_political_party_name] # Create scatter plot highchart() |> hc_add_series( data = party_ind_top, type = "scatter", hcaes( x = "standardised_political_party_name", y = "total_amount", group = "standardised_political_party_name" ) ) |> hc_xAxis( type = "category", categories = party_order ) |> hc_yAxis( title = list(text = "Number of Contributors"), labels = list( formatter = JS("function() { return this.value / 1000000 + 'M'; }") ) ) |> hc_title( text = "Top individual purchasers by Party", align = "left", style = list( textDecoration = "underline", color = "#333333", Weight = "bold" ) ) |> hc_plotOptions( scatter = list( color = "red", marker = list( radius = 4, symbol = "circle", lineWidth = 1 ), jitter = list(x = .2, y = 0) ) ) |> hc_legend(enabled = FALSE) |> hc_tooltip( formatter = JS(" function() { return 'Purchaser: ' + this.point.standardised_purchaser_name + '<br>Contribution: ₹' + (this.point.total_amount/1000000).toFixed(2) + 'M'; } ") ) |> hc_subtitle( text = "Electoral bond encashment between Apr 16, 2019 and Jan 24, 2024" ) |> hc_credits( enabled = TRUE, text = "Heteroscedasticity", href = "https://asitavsen.com", style = list(Size = "12px") ) |> hc_add_theme(custom_theme) |> hc_exporting( enabled = TRUE, filename = "IndividualsTop" )
To leave a comment for the author, please follow the link and comment on their blog: Heteroscedasticity.
R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.