0

Steps to reproduce my dataset.

library(tidyr) # Upgraded to --version 0.8.0.9000 with all fixes to unnest bugs. 

created_at <- c("2018-02-07T10:13:25Z", "2018-02-07T07:26:54Z", "2018-02-06T19:36:38Z", 
                 "2018-02-06T13:03:53Z")
labels <- list(structure(list(), .Names = character(0), row.names = integer(0), class = "data.frame"), 
    structure(list(id = 656178303L, url = "https://api.github.com/repos", 
                   name = "Project: ETHIOPIA", color = "006b75", default = FALSE), .Names = c("id", 
                                                                                                    "url", "name", "color", "default"), class = "data.frame", row.names = 1L), 
    structure(list(id = c(829717165L, 133781065L), url = c("https://api.github.com/repos/", 
                                                           "https://api.github.com/repos/"
    ), name = c("Pre Deployment", "help wanted"), color = c("159818", 
                                                            "159818"), default = c(FALSE, TRUE)), .Names = c("id", "url", 
                                                                                                             "name", "color", "default"), class = "data.frame", row.names = 1:2), 
    structure(list(id = 461737195L, url = "https://api.github.com/repos/", 
                   name = "Project: KENYA", color = "006b75", default = FALSE), .Names = c("id", 
                                                                                           "url", "name", "color", "default"), class = "data.frame", row.names = 1L))

df <- data.frame(cbind(created_at,labels))

df %>%
    unnest(labels)

This will work well when i run in Rstudio,but when i run in shiny app. I do get the

"Error : Each column must either be a list of vectors or a list of data frames [labels].

I notice that there is a bug filed at https://github.com/tidyverse/tidyr/issues/436 but why would running this in Rstudio work well and running on same environment but in Shiny app throw that Error.

EDITED: 

Solution that Fixed This in Shiny. I had to take out the NULL values first from the dataframe before introducing unnest().

df %>% 
  filter(!map_lgl(labels, ~all(is.na(.)))) %>% 
  mutate(labels = map(labels, bind_rows)) %>% 
  unnest() 
ngamita
  • 329
  • 2
  • 12
  • 1
    Do you have a minimal `shiny` repex to reproduce the error ? – dickoa Mar 15 '18 at 18:42
  • Don't name your variable `labels`. You get an error is because `labels` is a function name. Try to name it `my_labels` instead, and it will probably work. – GyD Mar 15 '18 at 22:01
  • 1
    Got a solution above. I had to remove the Empty dataframe lists before introducing unnest(). – ngamita Mar 16 '18 at 10:58

0 Answers0