r - Unimplemented type list when trying to write.table

r – Unimplemented type list when trying to write.table

r – Unimplemented type list when trying to write.table

Do this, irrespective of how many columns you have:

df <- apply(df,2,as.character)

Then do write.csv.

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

r – Unimplemented type list when trying to write.table

There is a new function (introduced in november 2016) in data.table package that handles writing a data.table object to csv quite well, even in those cases when a column of the data.table is a list.

fwrite(data.table, file =myDT.csv)

Related posts on R write table :

Leave a Reply

Your email address will not be published.