daroczig / fbRads

Analyze and manage Facebook ads from R using this client library to access their Marketing APIs
GNU Affero General Public License v3.0
153 stars 57 forks source link

Duplicate Row Names #82

Open laziob opened 6 years ago

laziob commented 6 years ago

Im using the fbad_list_ad function to get the active ads of a list of adsets ids, but for some reason I get an error of duplicate rownames. This only happens when getting the ads of different adsets at the same time.

testads <- fbad_list_ad(id = c("23842658373830776","23842658373930776","23842697638530776"), statuses = "ACTIVE", fields = c("campaign_id", "adset_id", "name", "creative")) Error in row.names<-.data.frame(*tmp*, value = value) : duplicate 'row.names' are not allowed In addition: Warning message: non-unique values when setting 'row.names': ‘1’, ‘2’

Any idea on how to solve it? Thanks and sorry for the trouble!

daroczig commented 6 years ago

See #81 for some more details, but in short, you want simplify=FALSE for now and do some postprocessing.

laziob commented 6 years ago

Haha Im the author of #81, a begginer to R and shiny so sorry for this type of questions :( I tried using simplify = FALSE and still get the same error though.

daroczig commented 6 years ago

Ah, sorry, I totally missed you are the author of both tickets :) Let me try to clarify this with some additional docs and suggested workaround -- later this week.

laziob commented 6 years ago

Thank you very much! Looking foward to it. If somehow I come up to a solution I'll keep you posted.

laziob commented 6 years ago

Just a headsup, the issue appears to be located on the do.call(rbind, res) of the fbad_list_ads function

Warning: non-unique values when setting 'row.names': ‘1’, ‘2’, ‘3’, ‘4’ Warning: Error in row.names<-.data.frame: duplicate 'row.names' are not allowed Stack trace (innermost first): 75: row.names<-.data.frame 74: row.names<- 73: rownames<- 72: rbind 71: 70: do.call 69: FUN 68: lapply 67: fbad_list_ad 66: getAds [funcionesFb.R#24] 65: observeEventHandler [C:\Users\LazioB\Documents\r_leadaki\r_leadaki\ShinyTuto/app.R#47] 1: runApp

daroczig commented 6 years ago

Hm, probably the simplify = FALSE option is handled correctly only if length(id) == 1 when using fbad_list_ads .. .can you please double check? If that's the case, then I think it's an easy fix in the package -- I was not actively using the batch feature of this function.

laziob commented 6 years ago

Exactly, when running fbad_list_ad with just 1 id, the simplify = FALSE works, but when running with vector, as example:
adlisttest2 <- fbad_list_ad(id = c("23842697638530776", "23842658373930776", "23842658373830776"), statuses = "ACTIVE", fields = c("campaign_id", "adset_id", "name", "creative"), simplify = FALSE)

it returns the Error in row.names<-.data.frame(*tmp*, value = value) : duplicate 'row.names' are not allowed

I tried modifying it locally on the package code to see if I could find a fix but had no luck due to lack of deeper knowledge 😢