Quantcast
Channel: Active questions tagged youtube-api - Stack Overflow
Viewing all articles
Browse latest Browse all 3831

Error in data.frame(channel_id = channel.df$id, title = channel.df$snippet.title, : arguments imply differing number of rows: 1, 0

$
0
0

I am working on this project with youtube API. The following is my code to retrive the data from the api url

for (channel_id in channel_ids) {  api_params1 <-    paste(paste0("key=", key),          paste0("id=", channel_id),"part=snippet,contentDetails,statistics",          sep = "&")  api_call1 <- paste0(base, "channels", "?", api_params1)  api_result1 <- GET(api_call1)  json_result1 <- content(api_result1, "text", encoding = "UTF-8")  channel.json <- fromJSON(json_result1, flatten = TRUE)  print(paste("Structure of channel.df for channel ID", channel_id, ":"))  str(channel.json)  channel.df <- channel.json$items  print(paste("Column names for channel ID", channel_id, ":"))  print(names(channel.df))  if ("items" %in% names(channel.json) && length(channel.json$items) > 0) {    channel.df <- channel.json$items    standardized_df <- data.frame(      channel_id = channel.df$id,      title = channel.df$snippet.title,      description = channel.df$snippet.description,      published_at = channel.df$snippet.publishedAt,      country = channel.df$snippet.country,      view_count = channel.df$statistics.viewCount,      subscriber_count = channel.df$statistics.subscriberCount,      hiddensub_count = channel.df$statistics.hiddenSubscriberCount,      video_count = channel.df$statistics.videoCount    )    channel_data_list[[channel_id]] <- standardized_df  }}all_channel_data <- do.call(rbind, channel_data_list)print(all_channel_data)

but i am getting this error which is limiting me to get the dataframe out of my code

Error in data.frame(channel_id = channel.df$id, title = channel.df$snippet.title, :  arguments imply differing number of rows: 1, 0

I tried using if condition but it seems to be not helping out.


Viewing all articles
Browse latest Browse all 3831

Trending Articles