Skip to content

Instantly share code, notes, and snippets.

@zerweck
Last active September 12, 2018 08:40
Show Gist options
  • Save zerweck/ff6f61f5d08986e1df56 to your computer and use it in GitHub Desktop.
Save zerweck/ff6f61f5d08986e1df56 to your computer and use it in GitHub Desktop.
[Export nested Lists] #R
# If you have nested lists or data.frames inside of a data.frame,
# print.data.frame can show these without help, but any variant
# of write.table will throw an error. This is because it uses the
# format.data.frame() function. This little function helps you do the same,
# so nested lists will be printed in one cell as long strings.
# To get the same output as print.data.frame, change the parameters as so:
## format.data.frame(df, digits = digits, na.encode = FALSE)
write.table.nested <- function(df, ...) {
df <- format.data.frame(df)
write.table(x = df, ...)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment