rstackexchange-api

How can I collect all questions with a specific tag?


I'm trying to use the Stack Exchange API to collect all questions under a specific tag using this code:

library(stackr)

df_r_questions <- stack_tags("python","questions", num_pages=1000000, pagesize=100)

However I receive this error:

Error in match.arg(special, c(special_ids, special_no_ids)) : 
  'arg' should be one of “faq”, “related”, “synonyms”, “wikis”, “info”, “moderator-only”, “required”

Any update I should make?


Solution

  • I think stack_tags returns information about the tags themselves, not questions with a particular tag. Perhaps you are looking for stack_questions?

    library(stackr)
    library(tidyverse)
    
    stack_questions(from = '2022-12-21', todate = '2022-12-22', tagged = 'r') %>%
      select(title) %>%
      as_tibble()
    #> # A tibble: 30 x 1
    #>    title                                                                      
    #>    <chr>                                                                     
    #>  1 How can one include Js code for rendering KaTeX by reactable in R Shiny?    
    #>  2 How to merge 2 vectors alternating indexes?                              
    #>  3 Select the first row by group                                            
    #>  4 How to sum a variable by group                                           
    #>  5 Aggregate / summarize multiple variables per group (e.g. sum, mean)        
    #>  6 Arrange by value, only if other conditions are satifisfied                 
    #>  7 Select rows were some column is equal to the max value for a group of ma~
    #>  8 How to assign correct projection and extent to a raster using terra r pa~
    #>  9 there is no package called &amp;quot;png&amp;quot;                      
    #> 10 Combine multiple xts objects created by getSymbols                      
    #> # ... with 20 more rows
    

    Created on 2022-12-23 with reprex v2.0.2