Unimplemented type list when trying to write.table

前端 未结 6 2145
说谎
说谎 2020-12-08 06:45

I have the following data.table (data.frame) called output:

> head(output)
        Id                                           Title IsProhibited
1 10000         


        
6条回答
  •  广开言路
    2020-12-08 07:08

    As mentioned in the comments, you should be able to do something like this (untested) to get "flatten" your list into a character vector:

    output$Title <- vapply(output$Title, paste, collapse = ", ", character(1L))
    

    As also mentioned, if you wanted to try the unlist approach, you could "expand" each row by the individual values in output$Title, something like this:

    x <- vapply(output$Title, length, 1L)          ## How many items per list element
    output <- output[rep(rownames(output), x), ]   ## Expand the data frame
    output$Title <- unlist(output$Title, use.names = FALSE)  ## Replace with raw values
    

提交回复
热议问题