Skip to content
#generative ai Open access

R Code for Regional Analysis: Automated Visualization and Image Export for Japanese Municipal Finance Using ggplot2 and patchwork 地域分析のためのRコード:ggplot2とpatchworkを用いた地方自治体財政指標の自動グラフ化および一括画像出力

Aug 2026 · Zenodo (CERN European Organization for Nuclear Research)

Abstract

本Rスクリプトは、地方財政分析のために設計された、ggplot2およびpatchworkを活用した自動・高性能なグラフィック生成モジュールである。先行リポジトリ(https://zenodo.org/records/20258441)で構築したデータ抽出パイプラインのシームレスな可視化拡張として機能し、論文・報告書クオリティの個別チャートや複数指標を統合したダッシュボードを自動生成する。処理済みの財政データセットを動的にスキャンし、厳密な数値フォーマット(%表記の小数点第1位固定など)を適用しながら、ファイルの上書き防止機能を備えた高解像度画像を一括エクスポートする。コードの厳密な再現性と即時利用性を検証するため、実行時に直接生成された未加工のサンプルグラフ(豊山町_公債費負担比率.png)を同梱している。 生成AIの利用について 本レポジトリのコード作成には生成AIを利用した。V1.0まではGoogle Gemini、V2.0以降はClaude(Anthropic)を用いて作成した。出力の検証は著者が行い、内容の責任は著者が負う。 Version 2.0 Release: 決算状況調10年パネルへの対応 本バージョン(V2.0)では、原データの系統を追加した。従来の「財政状況資料集」に加え、「市町村別決算状況調」から作成した10年パネル(平成27〜令和6年度、https://doi.org/10.5281/zenodo.22144642)を入力として扱える。作図モジュールは変更しておらず、入力を作る前段(prepare_panel_for_graphics.R)を追加することで対応した。描画対象は13指標で、目的別歳出から2款を含む。豊山町(愛知県)で実行したサンプル画像を同梱している。 関連Rコード 【類似団体検索・列挙ツール】二自治体の財政比較を行う場合に便利な類似団体コードの同一の自治体を検索・列挙するRコード(Shiny)を作成しました。https://doi.org/10.5281/zenodo.20387194 【連動データ抽出・処理モジュール】 本スクリプトでの可視化に必要な複数年の自治体財政指標データを抽出・前処理(「地方自治体財政指標に関する財政状況資料集を用いた10年間集計エクセルデータ作成」)する際は、基盤となるデータ処理モジュール( https://doi.org/10.5281/zenodo.20258441 )を参照のこと。 [English] R Code for Regional Analysis: Automated Visualization and Image Export Using ggplot2 and patchwork This R script provides an automated, high-performance graphic generation module designed for regional fiscal analysis, leveraging the power of ggplot2 and patchwork to produce publication-ready individual charts and integrated multi-indicator dashboards. Operating as a seamless visualization extension to the primary data extraction pipeline established in the preceding repository (available at https://zenodo.org/records/20258441 ), this module dynamically scans processed financial datasets, enforces rigorous decimal formatting (e.g., standardizing percentage representations to ".1f%"), and batch-exports high-resolution assets with native file-overwrite protection. To verify the script's strict reproducibility and out-of-the-box utility, the accompanying sample graph (豊山町_公債費負担比率.png, showing the Debt Service Burden Ratio of Toyoyama Town) is provided as a raw, unaltered file directly generated by the execution of this code. Declaration of Generative AI Use Generative AI was used to write the code in this repository. The code up to version 1.0 was written with Google Gemini; from version 2.0 it has been written with Claude (Anthropic). The author has verified the output and takes responsibility for the content. Version 2.0 Release: Support for the Settlement Survey Ten-Year Panel This version adds a second family of source data. Alongside the Financial Status Documents used since version 1.0, the module now accepts the ten-year panel (FY2015–FY2024) built from the Local Government Financial Settlement Survey (市町村別決算状況調), deposited at https://doi.org/10.5281/zenodo.22144642. The plotting module (compile_municipal_finance_10years_graphics.R) is unchanged. It takes a data frame of one fiscal year per row and decides how to draw each indicator from the column name alone: columns marked as amounts are drawn as bar charts, columns whose name contains the word for ratio as percentage lines, and the remainder as index lines. Because the interface is a data frame rather than a file format, supporting a different source requires only a new front end. The script added here, prepare_panel_for_graphics.R, selects one municipality from the panel by its code and assembles that data frame; the municipality and the expenditure categories to be drawn are set at the top of the script. Thirteen indicators are drawn. Six are amounts (total revenue, total expenditure, real balance, standard financial demand, standard financial revenue, standard fiscal scale), five are ratios or indices (index of financial capability, ratio of current expenditure to current revenue, real balance ratio, real debt service ratio, debt service burden ratio), and two are expenditure categories taken from the expenditure-by-purpose table (social welfare and civil engineering). Plotting expenditure categories over time is new in this version. Sample images produced by running the code on Toyoyama, Aichi Prefecture (municipality code 233421) are deposited as raw, unaltered output. Related R Code [Peer Municipality Search & Listing Tool] Developed an R Shiny application designed to search and list municipalities belonging to the same peer group code. This tool is highly useful for conducting comparative financial analysis between peer municipalities. https://doi.org/10.5281/zenodo.20387194 [Integrated Data Extraction & Processing Module] For extracting and preprocessing multi-year municipal financial indicator data required for visualization in this script (specifically, "Creating a 10-Year Aggregate Excel Dataset Using the Financial Status Documents on Local Government Financial Indicators"), please refer to the underlying data processing module. https://doi.org/10.5281/zenodo.20258441

View source

Similar papers

#artificial intelligence Conference Open access Apr 2020

ECCOLA - a Method for Implementing Ethically Aligned AI Systems

The method, ECCOLA, is presented, which aims at making the high-level AI ethics principles more practical, making it possible for developers to more easily implement them in practice.

Ville Vakkuri, Kai-Kristian Kemell, P. Abrahamsson · 64 citations · ⚡6
#computer vision Review Apr 2024

AI-powered Code Review with LLMs: Early Results

The goal is to not only refine the accuracy of the LLM-based tool but also to underscore its potential in streamlining the software development lifecycle through proactive code improvement and education.

Z. Rasheed, Malik Abdul Sami, Muhammad Waseem et al. · 62 citations · ⚡3
#computer vision Open access Mar 2024

LLM-based agents for automating the enhancement of user story quality: An early report

The use of large language models to automatically improve the user story quality in Austrian Post Group IT agile teams is explored, with a reference model for an Autonomous LLM-based Agent System developed and implemented at the company.

Zheying Zhang, M. Rayhan, Tomas Herda et al. · 48 citations · ⚡4
#computer vision Review Mar 2024

System for systematic literature review using multiple AI agents: Concept and an empirical evaluation

This paper introduces a novel multi-AI-agent system designed to fully automate SLRs, and demonstrates how it substantially reduces the time and effort traditionally required for SLRs while maintaining comprehensiveness and precision.

Abdul Malik Sami, Z. Rasheed, Kai-Kristian Kemell et al. · 44 citations · ⚡2
#computer vision Feb 2024

Can Large Language Models Serve as Data Analysts? A Multi-Agent Assisted Approach for Qualitative Data Analysis

The proposed LLM-based multi-agent system automates qualitative data analysis process, creating opportunities for researchers and practitioners, and future improvements focus on enhancing multilingual performance and integrating continuous expert feedback.

Z. Rasheed, Muhammad Waseem, Aakash Ahmad et al. · 41 citations

Related blog posts

MIT News · Artificial Intelligence Oct 15, 2026

AI model decodes the language cells use to communicate

A new computational approach reveals how cells communicate to assemble into tissues. This could accelerate stem cell engineering, improve disease models, and inform therapies.

We use cookies to run the site and, with your consent, for analytics and to show ads. See our Cookie Policy.