### Example Usage of estat_getStatsList Source: https://yutannihilation.github.io/estatapi/reference/estat_getStatsList.html Demonstrates how to call the estat_getStatsList function with essential parameters like appId, searchWord, and limit. ```R if (FALSE) { estat_getStatsList( appId = "XXXX", searchWord = "CD", limit = 3 ) } ``` -------------------------------- ### Install estatapi from CRAN Source: https://yutannihilation.github.io/estatapi/index.html Install the estatapi package from the Comprehensive R Archive Network (CRAN). This is the standard method for installing stable releases. ```r install.packages("estatapi") ``` -------------------------------- ### Install estatapi Development Version Source: https://yutannihilation.github.io/estatapi/index.html Install the development version of the estatapi package directly from GitHub using the devtools package. This is useful for accessing the latest features or bug fixes. ```r devtools::install_github("yutannihilation/estatapi") ``` -------------------------------- ### Example Usage of estat_getDataCatalog Source: https://yutannihilation.github.io/estatapi/reference/estat_getDataCatalog.html This example demonstrates how to call the `estat_getDataCatalog` function with specific parameters to search for Excel data related to 'CD' and limit the results to 3. ```R estat_getDataCatalog( appId = "XXXX", searchWord = "CD", dataType = "XLS", limit = 3 ) ``` -------------------------------- ### Limit Records Fetched by estat_getStatsData Source: https://yutannihilation.github.io/estatapi/reference/estat_getStatsData.html Fetches a limited number of records (up to 10 in this example) for a given dataset. Useful for testing or when only a subset is needed. ```R estat_getStatsData( appId = "XXXX", statsDataId = "0003065345", limit = 10 ) ``` -------------------------------- ### Get Meta Information for a Statistic Source: https://yutannihilation.github.io/estatapi/index.html Retrieves metadata for a specific statistical dataset using its ID. The result is a list where each element is a tbl_df containing metadata for a data item. ```r meta_info <- estat_getMetaInfo(appId = appId, statsDataId = "0003103532") names(meta_info) #> [1] "tab" "cat01" "cat02" "area" "time" ".names" meta_info$cat01 #> # A tibble: 703 x 5 #> `@code` `@name` `@level` `@unit` `@parentCode` #> * #> 1 000100000 世帯数分布(抽出率調整) 1 一万分比 #> 2 000200000 集計世帯数 1 世帯 #> 3 000300000 世帯人員 1 人 #> 4 000400000 18歳未満人員 2 人 000300000 #> 5 000500000 65歳以上人員 2 人 000300000 #> 6 000600000 65歳以上無職者人員 3 人 000500000 #> 7 000700000 有業人員 1 人 #> 8 000800000 世帯主の年齢 1 歳 #> 9 000900000 持家率 1 % #> 10 001000000 家賃・地代を支払っている世帯の割合 1 % #> # … with 693 more rows ``` -------------------------------- ### Get Limited Statistics Data Source: https://yutannihilation.github.io/estatapi/index.html Retrieves a limited number of statistical records using `limit` and `startPosition` parameters. This is useful for previewing data or fetching data in chunks. ```r estat_getStatsData( appId = appId, statsDataId = "0003103532", cdCat01 = c("010800130","010800140"), limit = 3 ) #> Fetching record 1-3... (total: 17792 records) #> # A tibble: 3 x 13 #> tab_code 表章項目 cat01_code `品目分類(27年改定)`… cat02_code 世帯区分 area_code #> * #> 1 01 金額 010800130 352 チョコレート 03 二人以上の世帯… 00000 #> 2 01 金額 010800130 352 チョコレート 03 二人以上の世帯… 00000 #> 3 01 金額 010800130 352 チョコレート 03 二人以上の世帯… 00000 #> # … with 6 more variables: 地域区分 , time_code , #> `時間軸(月次)` , unit , value , annotation ``` ```r estat_getStatsData( appId = appId, statsDataId = "0003103532", cdCat01 = c("010800130","010800140"), startPosition = 101, limit = 3 ) #> Fetching record 101-103... (total: 17792 records) #> # A tibble: 3 x 13 #> tab_code 表章項目 cat01_code `品目分類(27年改定)`… cat02_code 世帯区分 area_code #> * #> 1 01 金額 010800130 352 チョコレート 03 二人以上の世帯… 00000 #> 2 01 金額 010800130 352 チョコレート 03 二人以上の世帯… 00000 #> 3 01 金額 010800130 352 チョコレート 03 二人以上の世帯… 00000 #> # … with 6 more variables: 地域区分 , time_code , #> `時間軸(月次)` , unit , value , annotation ``` -------------------------------- ### Get Statistics Data with Filtering Source: https://yutannihilation.github.io/estatapi/index.html Retrieves statistical data, returning a tbl_df. It's recommended to filter by `cdCat01` or other parameters to reduce data size and retrieval time. Refer to official documentation for all filtering parameters. ```r estat_getStatsData( appId = appId, statsDataId = "0003103532", cdCat01 = c("010800130","010800140") ) #> Fetching record 1-17792... (total: 17792 records) #> # A tibble: 17,792 x 13 #> tab_code 表章項目 cat01_code `品目分類(27年改定)`… cat02_code 世帯区分 area_code #> * #> 1 01 金額 010800130 352 チョコレート 03 二人以上の世帯… 00000 #> 2 01 金額 010800130 352 チョコレート 03 二人以上の世帯… 00000 #> 3 01 金額 010800130 352 チョコレート 03 二人以上の世帯… 00000 #> 4 01 金額 010800130 352 チョコレート 03 二人以上の世帯… 00000 #> 5 01 金額 010800130 352 チョコレート 03 二人以上の世帯… 00000 #> 6 01 金額 010800130 352 チョコレート 03 二人以上の世帯… 00000 #> 7 01 金額 010800130 352 チョコレート 03 二人以上の世帯… 00000 #> 8 01 金額 010800130 352 チョコレート 03 二人以上の世帯… 00000 #> 9 01 金額 010800130 352 チョコレート 03 二人以上の世帯… 00000 #> 10 01 金額 010800130 352 チョコレート 03 二人以上の世帯… 00000 #> # … with 17,782 more rows, and 6 more variables: 地域区分 , cat02_code , 世帯区分 , area_code , 地域区分 , time_code , #> `時間軸(月次)` , unit , value , annotation ``` -------------------------------- ### Basic Usage of estat_getStatsData Source: https://yutannihilation.github.io/estatapi/reference/estat_getStatsData.html Fetches all available statistical data for a given appId and statsDataId. This can take a significant amount of time. ```R estat_getStatsData( appId = "XXXX", statsDataId = "0003065345" ) ``` -------------------------------- ### Search for Statistics with Labels Source: https://yutannihilation.github.io/estatapi/index.html Search for statistical tables related to 'チョコレート' (chocolate) using the estat_getStatsList function. The results are returned with human-readable labels for fields like STAT_NAME and GOV_ORG. ```r library(estatapi) #> このサービスは、政府統計の総合窓口(e-Stat)のAPI機能を使用していますが、サービスの内容は国によって保証されたものではありません。 estat_getStatsList(appId = appId, searchWord = "チョコレート") #> # A tibble: 241 x 22 #> `@id` STAT_NAME GOV_ORG STATISTICS_NAME TITLE CYCLE SURVEY_DATE OPEN_DATE #> * #> 1 0000… 全国物価統計調査… 総務省 平成9年全国物価統計調査 大… 価格分布… - 199711 2007-09-… #> 2 0000… 全国物価統計調査… 総務省 平成9年全国物価統計調査 小… 価格分布… - 199711 2007-09-… #> 3 0000… 全国物価統計調査… 総務省 平成9年全国物価統計調査 消… 指数銘柄… - 199711 2007-09-… #> 4 0000… 全国物価統計調査… 総務省 平成9年全国物価統計調査 消… 指数銘柄… - 199711 2007-09-… #> 5 0000… 全国物価統計調査… 総務省 平成9年全国物価統計調査 消… 品目・銘… - 199711 2007-09-… #> 6 0000… 全国物価統計調査… 総務省 平成9年全国物価統計調査 消… 品目・銘… - 199711 2007-09-… #> 7 0000… 全国物価統計調査… 総務省 平成9年全国物価統計調査 消… 品目・銘… - 199711 2007-09-… #> 8 0000… 全国物価統計調査… 総務省 平成9年全国物価統計調査 消… 品目・銘… - 199711 2007-09-… #> 9 0003… 工業統計調査… 経済産業省… 工業統計調査 確報 平成25… 品目編 … 年次 201301-201… 2015-05-… #> 10 0003… 工業統計調査… 経済産業省… 工業統計調査 確報 平成26… 品目編 … 年次 201401-201… 2016-04-… #> # … with 231 more rows, and 14 more variables: SMALL_AREA , #> # COLLECT_AREA , MAIN_CATEGORY , SUB_CATEGORY , #> # OVERALL_TOTAL_NUMBER , UPDATED_DATE , TABULATION_CATEGORY , #> # TABULATION_SUB_CATEGORY1 , DESCRIPTION , TABLE_CATEGORY , #> # TABLE_NAME , TABULATION_SUB_CATEGORY2 , #> # TABLE_SUB_CATEGORY1 , TABULATION_SUB_CATEGORY3 ``` -------------------------------- ### Fetch Max Records (100,000) with estat_getStatsData Source: https://yutannihilation.github.io/estatapi/reference/estat_getStatsData.html Fetches the maximum number of records (100,000) available at once without fetching all records if the total exceeds this limit. Set .fetch_all to FALSE. ```R estat_getStatsData( appId = "XXXX", statsDataId = "0003065345", .fetch_all = FALSE ) ``` -------------------------------- ### estat_getStatsList Function Signature Source: https://yutannihilation.github.io/estatapi/reference/estat_getStatsList.html This is the function signature for estat_getStatsList, outlining all available arguments and their default values. ```R estat_getStatsList( appId, searchWord, lang = c("J", "E"), .use_label = TRUE, surveyYears = NULL, openYears = NULL, statsField = NULL, statsCode = NULL, searchKind = NULL, collectArea = NULL, startPosition = NULL, limit = NULL, updatedDate = NULL, ... ) ``` -------------------------------- ### Search for Statistics with Codes Source: https://yutannihilation.github.io/estatapi/index.html Search for statistical tables related to 'チョコレート' (chocolate) using estat_getStatsList, with the option to suppress human-readable labels and return raw codes for fields like STAT_NAME and GOV_ORG. This is useful for programmatic handling of the data. ```r estat_getStatsList(appId = appId, searchWord = "チョコレート", .use_label = FALSE) #> # A tibble: 241 x 22 #> `@id` STAT_NAME GOV_ORG STATISTICS_NAME TITLE CYCLE SURVEY_DATE OPEN_DATE #> * #> 1 0000… 00200572 00200 平成9年全国物価統計調査 大… 009 - 199711 2007-09-… #> 2 0000… 00200572 00200 平成9年全国物価統計調査 小… 009 - 199711 2007-09-… #> 3 0000… 00200572 00200 平成9年全国物価統計調査 消… 007 - 199711 2007-09-… #> 4 0000… 00200572 00200 平成9年全国物価統計調査 消… 008 - 199711 2007-09-… #> 5 0000… 00200572 00200 平成9年全国物価統計調査 消… 009 - 199711 2007-09-… #> 6 0000… 00200572 00200 平成9年全国物価統計調査 消… 010 - 199711 2007-09-… #> 7 0000… 00200572 00200 平成9年全国物価統計調査 消… 011 - 199711 2007-09-… #> 8 0000… 00200572 00200 平成9年全国物価統計調査 消… 012 - 199711 2007-09-… #> 9 0003… 00550010 00550 工業統計調査 確報 平成25… 1-05 年次 201301-201… 2015-05-… #> 10 0003… 00550010 00550 工業統計調査 確報 平成26… 1-05 年次 201401-201… 2016-04-… #> # … with 231 more rows, and 14 more variables: SMALL_AREA , #> # COLLECT_AREA , MAIN_CATEGORY , SUB_CATEGORY , #> # OVERALL_TOTAL_NUMBER , UPDATED_DATE , TABULATION_CATEGORY , #> # TABULATION_SUB_CATEGORY1 , DESCRIPTION , TABLE_CATEGORY , #> # TABLE_NAME , TABULATION_SUB_CATEGORY2 , #> # TABLE_SUB_CATEGORY1 , TABULATION_SUB_CATEGORY3 ``` -------------------------------- ### Set Application ID Source: https://yutannihilation.github.io/estatapi/index.html Set your application ID obtained from the e-Stat portal. This ID is required for making API requests. ```r appId <- "XXXXXXXXX" ``` -------------------------------- ### estat_getStatsList Source: https://yutannihilation.github.io/estatapi/reference/estat_getStatsList.html Searches for statistical datasets using the e-Stat API. It allows filtering by keywords, language, survey years, statistics field, and more. ```APIDOC ## estat_getStatsList ### Description Searches for statistical datasets via the e-Stat API. This function allows for flexible searching based on keywords, language, survey years, and other specific criteria. ### Method Not applicable (R function) ### Endpoint Not applicable (R function) ### Parameters #### Arguments - **appId** (string) - Required - Application ID. - **searchWord** (string) - Required - Keyword for searching. Can use `OR` and `AND` to combine conditions (e.g.: `"apple AND orange"`). - **lang** (string) - Optional - Language of the data. Accepts `"J"`(Japanese) or `"E"`(English). - **.use_label** (boolean) - Optional - Whether to take the human-readable label value or the code value when flattening a field containing both (default: `TRUE`). - **surveyYears** (string) - Optional - Year and month when the survey was conducted. Format: `"YYYY"`, `"YYYYMM"`, or `"YYYYMM-YYYYMM"`. - **openYears** (string) - Optional - Year and month when the survey result was opened. Format is the same as `surveyYears`. - **statsField** (string) - Optional - Field of statistics. Format: two digits (large classification) or four digits (small classification). - **statsCode** (string) - Optional - Code assigned for each statistical agency and statistics. Format: five digits (agency), and eight digits (statistics). - **searchKind** (string) - Optional - Type of statistics. Accepts `1` for summary or `2` for regional mesh. - **collectArea** (string) - Optional - Area of statistics. Accepts `1` for country, `2` for prefecture, or `3` for municipality. - **startPosition** (integer) - Optional - Index of the first record to get. - **limit** (integer) - Optional - Max number of records to get. - **updatedDate** (string) - Optional - Last updated date. Format: `"YYYY"`, `"YYYYMM"`, or `"YYYYMM-YYYYMM"`. - **...** - Optional - Other parameters. ### Request Example ```R estat_getStatsList( appId = "XXXX", searchWord = "CD", limit = 3 ) ``` ### Response (Response details not specified in the source text) ### See Also - http://www.e-stat.go.jp/api/e-stat-manual3-0/#api_2_1 - http://www.e-stat.go.jp/api/e-stat-manual3-0/#api_3_2 ``` -------------------------------- ### estat_getDataCatalog Source: https://yutannihilation.github.io/estatapi/reference/estat_getDataCatalog.html Retrieves information about statistical datasets and databases. This function allows for flexible querying using parameters like application ID, language, survey years, search terms, data types, and more. ```APIDOC ## estat_getDataCatalog ### Description Retrieves information about statistical datasets and databases. This function allows for flexible querying using parameters like application ID, language, survey years, search terms, data types, and more. ### Method GET ### Endpoint /getDataCatalog ### Parameters #### Query Parameters - **appId** (string) - Required - Application ID. - **lang** (string) - Optional - Language of the data. "J"(Japanese) or "E"(English). - **.use_label** (boolean) - Optional - Whether to take the human-readable label value or the code value when flattening a field containing both (default: TRUE). - **surveyYears** (string) - Optional - Year and month when the survey was conducted. The format is either "YYYY", "YYYYMM", or "YYYYMM-YYYYMM". - **openYears** (string) - Optional - Year and month when the survey result was opened. The format is the same as `surveyYears`. - **statsField** (string) - Optional - Field of statistics. The format is either two digits (large classification) or four digits (small classification). - **statsCode** (string) - Optional - Code assigned for each statistical agency and statistics. The format can be five digits (agency), and eight digits (statistics). - **searchWord** (string) - Optional - Keyword for searching. You can use `OR` and `AND` to combine conditions (e.g.: "apple AND orange"). - **dataType** (string) - Optional - Type of data. `XLS`: Excel file, `CSV`: CSV file, `PDF`: PDF file, `DB`: Database. - **catalogId** (string) - Optional - Catalog ID. - **resourceId** (string) - Optional - Catalog resource ID. - **startPosition** (integer) - Optional - Index of the first record to get. - **limit** (integer) - Optional - Max number of records to get. - **updatedDate** (string) - Optional - Last updated date. The format is either "YYYY", "YYYYMM", or "YYYYMM-YYYYMM". ### Request Example ```json { "appId": "XXXX", "searchWord": "CD", "dataType": "XLS", "limit": 3 } ``` ### Response #### Success Response (200) (Response structure not explicitly defined in source, but implies a catalog of datasets) #### Response Example (Example response not explicitly defined in source) ``` -------------------------------- ### estat_getDataCatalog Function Signature Source: https://yutannihilation.github.io/estatapi/reference/estat_getDataCatalog.html This is the function signature for `estat_getDataCatalog`. It outlines all available parameters for querying the e-Stat API's data catalog. ```R estat_getDataCatalog( appId, lang = c("J", "E"), .use_label = TRUE, surveyYears = NULL, openYears = NULL, statsField = NULL, statsCode = NULL, searchWord = NULL, dataType = NULL, catalogId = NULL, resourceId = NULL, startPosition = NULL, limit = NULL, updatedDate = NULL, ... ) ``` -------------------------------- ### Fetch Data by Category with estat_getStatsData Source: https://yutannihilation.github.io/estatapi/reference/estat_getStatsData.html Fetches statistical data filtered by specific categories (cdCat01). The category codes are provided as a character vector. ```R estat_getStatsData( appId = "XXXX", statsDataId = "0003065345", cdCat01 = c("008", "009", "010") ) ``` -------------------------------- ### estat_getStatsData Source: https://yutannihilation.github.io/estatapi/reference/estat_getStatsData.html Fetches statistical data from the e-Stat API. It allows specifying application ID, dataset ID, and various filtering and pagination options. ```APIDOC ## estat_getStatsData ### Description Retrieves statistical data using the e-Stat API. This function allows fetching data with specified parameters such as application ID, dataset ID, start position, limit, and language. ### Method Not applicable (R function) ### Endpoint Not applicable (R function) ### Parameters #### Arguments - **appId** (string) - Required - Application ID. - **statsDataId** (string) - Required - ID of the statistical dataset. - **startPosition** (integer) - Optional - Index of the first record to get. - **limit** (integer) - Optional - Max number of records to get. - **lang** (character vector) - Optional - Language of the data. Accepts "J" (Japanese) or "E" (English). - **.fetch_all** (boolean) - Optional - Whether to fetch all records when the number of records is larger than 100,000. Defaults to TRUE. - **...** (any) - Optional - Other parameters including: - **lvTab** (string) - Level of the meta-information. Format: `X` or `X-Y`, `-X` and `X-`. - **cdTab** (character vector or string) - Code(s) of the meta-information items to select. Format: `c("001", "002")` or `"001,002"`. - **cdTabFrom** (string) - The code of the first meta-information item to select. - **cdTabTo** (string) - The code of the last meta-information item to select. - **lvTime** (string) - Level of the time to select. Format is the same as `lvTab`. - **cdTime** (character vector or string) - Time(s) to select. Format is the same way like `cdTab`. - **cdTimeFrom** (string) - The first time to select. Format is the same way like `cdTabFrom`. - **cdTimeTo** (string) - The last time to select. Format is the same way like `cdTabTo`. - **lvArea** (string) - Level of the area to select. Format is the same as `lvTab`. - **cdArea** (character vector or string) - Code(s) of the Area to select. Format is the same way like `cdTab`. - **cdAreaFrom** (string) - The code of the first area to select. Format is the same way like `cdTabFrom`. - **cdAreaTo** (string) - The code of the last area to select. Format is the same way like `cdTabTo`. - **lvCat01**, **cdCat01**, **cdCat01From**, **cdCat01To**, ... - Similar parameters for categories. ### Request Example ```R # Fetch all data estat_getStatsData( appId = "XXXX", statsDataId = "0003065345" ) # Fetch data up to 10 records estat_getStatsData( appId = "XXXX", statsDataId = "0003065345", limit = 10 ) # Fetch data up to 100,000 records (max number of records available at once) estat_getStatsData( appId = "XXXX", statsDataId = "0003065345", .fetch_all = FALSE ) # Fetch all data in the specified category estat_getStatsData( appId = "XXXX", statsDataId = "0003065345", cdCat01 = c("008", "009", "010") ) ``` ### Response Details on the response structure are not provided in the source. The function is expected to return the fetched statistical data. ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.