facebookresearch / Radlibrary

An R package for accessing the Facebook Ad Library API

Home Page:https://facebookresearch.github.io/Radlibrary/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ad_table fails when "impressions" and "spend" are not in fields

colin-fraser opened this issue · comments

library(tibble)
library(Radlibrary)
query <- adlib_build_query(ad_reached_countries = 'US', 
                           ad_active_status = 'ALL', 
                           impression_condition = 'HAS_IMPRESSIONS_LAST_90_DAYS', 
                           ad_type = c("POLITICAL_AND_ISSUE_ADS"),
                           search_page_ids = "153080620724", ## DJT's page FB id 
                           fields = c("ad_snapshot_url"), limit = 10)

result <- adlib_get(query)

as_tibble(result, 'ad')  # ad table (you'll see a lot of NAs)
#> Error: Tibble columns must have consistent lengths, only values of length one are recycled:
#> * Length 0: Columns `spend_lower`, `impressions_lower`
#> * Length 10: Columns `ad_creation_time`, `ad_creative_body`, `ad_creative_link_caption`, `ad_creative_link_description`, `ad_creative_link_title`, … (and 10 more)

Created on 2020-01-09 by the reprex package (v0.3.0)