knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "man/figures/README-", out.width = "100%" )
The goal of thaigov is to provide an easy access to the datasets on the Open Government Data of Thailand API from R. The Thai documentation of the API can be viewed here: https://opendata.data.go.th/pages/data-go-th-api.
เป้าหมายของ thaigov แพ็คเก็จคือการทำให้ผู้ใช้ R สามารถเข้าถึงข้อมูลเปิดของรัฐบาลไทยได้ง่ายยิ่งขึ้น คุณสามารถอ่านรายละเอียดของ API ได้ที่ https://opendata.data.go.th/pages/data-go-th-api
You can install the development version of thaigov from GitHub with:
ติดตั้งแพ็คเกจได้จาก GitHub โดยใช้โค้ดดังต่อไปนี้:
# install.packages("devtools") devtools::install_github("asiripanich/thaigov")
First put your Open Government Data of Thailand API key in your machine's .Renviron file.
I normally use usethis::edit_r_environ() to find and open my .Renviron file.
Insert the your API key in the following format: THGOV_OPENDATA_TOKEN=<your-API-key>.
ก่อนอื่นเราต้องบันทึกค่า API คีย์ไปยัง .Renviron ไฟล์ ซึ่งคุณสามารถใช้ usethis::edit_r_environ() ในการเปิดไฟล์ขึ้นมา
จากนั้นให้นำ API คีย์ลงไปใส่ดังต่อไปนี้ THGOV_OPENDATA_TOKEN=<your-API-key>
library(thaigov) library(tibble) covid_resources <- th_resource_search("name:COVID-19") # search for resources that contain the word "COVID" in Thai in their description. covid_resources %>% as_tibble() covid_csv_datasets <- covid_resources %>% .[format == "CSV" & !is.na(id), id] %>% lapply(function(x) th_get(x, limit = 100) %>% as_tibble()) covid_csv_datasets th_package_list() %>% sample(size = 10) # th_package_search("โควิด") # search for packages that contain the word "COVID" in Thai. # th_package_show("3e9d9124-d187-4fc7-b2fb-22c681ceb4fe")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.