Extract only numbers from a list

Asked

Viewed 133 times

1

I’m using the package on the R fbRads to collect data from Facebook Ads. However, when I turn it into a data frame, I get a list of the values, rather than the numerical value. How can I separate just this amount?

library(fbRads)
library(tidyr)
library(jsonlite)
library(googlesheets)
library(stringr)
auth = fbad_init("", "", version='3.0')
Facebook = fb_insights(auth, time_increment="1", level="ad", fields =         
toJSON(c("impressions", "date_start", "ad_name", "adset_name", 
"campaign_name", "clicks", "spend", "inline_post_engagement", 
"video_10_sec_watched_actions","video_avg_percent_watched_actions", 
"video_p95_watched_actions", "actions", "link_click")))
Facebook = as.data.frame(do.call(rbind, Facebook))
data.frame(t(sapply(Facebook,c)))

I get this list of outputs as a response. I need each of these to be a separate column in the standard dataframe.

  • Lucas, edit your question with the text in Portuguese. And, if possible, make available the part of your code that you are using to facilitate the answers.

  • Put an example of the output obtained and the expected output, this can help people to respond.

  • 1

    Do not put pictures, copy the output and post this output as text, please.

  • 1

    look for the functions unnest and spread package tidyr. Your chances of getting a better answer would increase greatly if you put at least one piece of this object Facebook. You can, for example, at the end of the question put the result of dput(head(Facebook)).

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.