{"id":16036565,"url":"https://github.com/dgrtwo/stackbigquery","last_synced_at":"2025-10-29T11:49:26.103Z","repository":{"id":149051353,"uuid":"405118101","full_name":"dgrtwo/stackbigquery","owner":"dgrtwo","description":"Database-specific package for the Stack Overflow data on Google BigQuery","archived":false,"fork":false,"pushed_at":"2021-09-10T15:01:33.000Z","size":96,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-05T05:13:35.077Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dgrtwo.png","metadata":{"files":{"readme":"README.Rmd","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-09-10T14:59:56.000Z","updated_at":"2022-12-11T18:18:07.000Z","dependencies_parsed_at":"2023-04-26T17:31:54.609Z","dependency_job_id":null,"html_url":"https://github.com/dgrtwo/stackbigquery","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/dgrtwo/stackbigquery","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dgrtwo%2Fstackbigquery","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dgrtwo%2Fstackbigquery/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dgrtwo%2Fstackbigquery/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dgrtwo%2Fstackbigquery/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dgrtwo","download_url":"https://codeload.github.com/dgrtwo/stackbigquery/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dgrtwo%2Fstackbigquery/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":281616665,"owners_count":26531918,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-29T02:00:06.901Z","response_time":59,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-08T22:05:44.867Z","updated_at":"2025-10-29T11:49:26.069Z","avatar_url":"https://github.com/dgrtwo.png","language":"R","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003c!-- README.md is generated from README.Rmd. Please edit that file --\u003e\n\n```{r, include = FALSE}\nknitr::opts_chunk$set(\n  collapse = TRUE,\n  comment = \"#\u003e\",\n  fig.path = \"man/figures/README-\",\n  out.width = \"100%\",\n  cache = TRUE,\n  cache.path = \"README-cache/\"\n)\n```\n\n# stackbigquery\n\n\u003c!-- badges: start --\u003e\n\u003c!-- badges: end --\u003e\n\nstackbigquery is a package wrapping the Stack Overflow database on Google BigQuery.\n\nThis is a minimal example of using [dbcooper](https://github.com/dgrtwo/dbcooper) to create a database package:\n\n* Create a connection in [connections.R](https://github.com/dgrtwo/stackbigquery/blob/master/R/connections.R)\n* Run `dbcooper::dbc_init()` on that connection in [zzz.R](https://github.com/dgrtwo/stackbigquery/blob/master/R/zzz.R)\n* Put package-specific functions in other files like  [summarize.R](https://github.com/dgrtwo/stackbigquery/blob/master/R/summarize.R)\n\n## Installation\n\nYou can install the development version of stackbigquery from GitHub with:\n\n``` r\ndevtools::install_github(\"dgrtwo/stackbigquery\")\n```\n\nYou'll also need to create a Google Cloud project with BigQuery enabled, and set two environment variables in your `.Renviron` file (see [bigrquery](https://bigrquery.r-dbi.org/)).\n\n```\nBIGQUERY_BILLING_PROJECT=\u003cyour_project\u003e\nBIGQUERY_EMAIL=\u003cyour_email\u003e\n```\n\nThe first time you use the package, it may prompt you to authenticate (see the [gargle](https://gargle.r-lib.org/) package for more).\n\n## Examples\n\nOnce you've loaded the stackbigquery package, you can use functions prefixed with `stack_` to access the database. This includes\n\n* `stack_list()` to list tables in the database\n* `stack_query()` to run a SQL query (and get a remote dbplyr table)\n\n```{r posts_questions}\nlibrary(dplyr)\nlibrary(stackbigquery)\n\nstack_list()\nstack_query(\"SELECT * FROM tags ORDER BY count DESC\")\n```\n\nYou can also use autocomplete-friendly table accessors:\n\n```{r}\nstack_posts_questions()\n```\n\nThese can be used with dbplyr to do joins or summaries.\n\n```{r by_month}\nby_month \u003c- stack_posts_questions() %\u003e%\n  group_by(month = DATE_TRUNC(DATE(creation_date), MONTH)) %\u003e%\n  summarize(n_questions = n(),\n            avg_score = mean(score),\n            avg_answers = mean(answer_count)) %\u003e%\n  collect()\n\nby_month\n```\n\n```{r}\nlibrary(ggplot2)\ntheme_set(theme_light())\n\nby_month %\u003e%\n  filter(n_questions \u003e= 100) %\u003e%\n  ggplot(aes(month, avg_score)) +\n  geom_line() +\n  labs(y = \"Average score of Stack Overflow questions\")\n```\n\n### Summarize tags\n\nAs a database-specific package, stackbigquery also offers useful verbs for doing common operations on the data.\n\nFor instance, `summarize_tags` takes a (potentially grouped) version of `stack_posts_questions`, joins it to the tags table, and aggregates the frequency by tag.\n\n```{r by_month_tag}\nby_month_tag \u003c- stack_posts_questions() %\u003e%\n    group_by(month = DATE_TRUNC(DATE(creation_date), MONTH)) %\u003e%\n    summarize_tags(c(\"javascript\", \"java\", \"python\", \"c#\", \"php\", \"c++\"))\n\nby_month_tag\n```\n\n```{r by_month_tag_plot, dependson = \"by_month_tag\"}\nlibrary(ggplot2)\nlibrary(forcats)\n\nby_month_tag %\u003e%\n  filter(month != max(month),\n         month != min(month)) %\u003e%\n  arrange(month) %\u003e%\n  mutate(tag = fct_reorder(tag, -percent, last)) %\u003e%\n  ggplot(aes(month, percent, color = tag)) +\n  geom_line() +\n  scale_y_continuous(labels = scales::percent_format()) +\n  expand_limits(y = 0) +\n  labs(x = \"Time\",\n         y = \"% of Stack Overflow questions\")\n```\n\n### Code of Conduct\n\nPlease note that the 'stackbigquery' project is released with a [Contributor Code of Conduct](CODE_OF_CONDUCT.md). By contributing to this project, you agree to abide by its terms.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdgrtwo%2Fstackbigquery","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdgrtwo%2Fstackbigquery","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdgrtwo%2Fstackbigquery/lists"}