I’m attempting to write a data frame to csv but it seems to be complaining because the columns contain lists.
I want to be able to do is access this data frame and call it into R at a later time. I don’t care how to accomplish this (save as a text file etc). This is a fairly large data set n=182305. Any ideas to write it to a file that I can fairly quickly read into R (I’m not married to a csv file)
DATA Frame & the Code I’ve Tried
DF2<-structure(list(word = c("3-D", "4-F", "4-H'er", "4-H", "A battery",
"a bon march"), pos.code = c("AN", "N", "N", "A", "h", "v"),
pos = list(c("A", "N"), "N", "N", "A", "h", "v"), noun = list(
TRUE, TRUE, TRUE, FALSE, FALSE, FALSE), plural = list(
FALSE, FALSE, FALSE, FALSE, FALSE, FALSE), noun.phrase = list(
FALSE, FALSE, FALSE, FALSE, TRUE, FALSE), verb.usually.participle = list(
FALSE, FALSE, FALSE, FALSE, FALSE, FALSE), transitive.verb = list(
FALSE, FALSE, FALSE, FALSE, FALSE, FALSE), intransitive.verb = list(
FALSE, FALSE, FALSE, FALSE, FALSE, FALSE), adjective = list(
TRUE, FALSE, FALSE, TRUE, FALSE, FALSE), adverb = list(
FALSE, FALSE, FALSE, FALSE, FALSE, TRUE), conjunction = list(
FALSE, FALSE, FALSE, FALSE, FALSE, FALSE), preposition = list(
FALSE, FALSE, FALSE, FALSE, FALSE, FALSE), interjection = list(
FALSE, FALSE, FALSE, FALSE, FALSE, FALSE), pronoun = list(
FALSE, FALSE, FALSE, FALSE, FALSE, FALSE), definite.article = list(
FALSE, FALSE, FALSE, FALSE, FALSE, FALSE), indefinite.article = list(
FALSE, FALSE, FALSE, FALSE, FALSE, FALSE), nominative = list(
FALSE, FALSE, FALSE, FALSE, FALSE, FALSE)), .Names = c("word",
"pos.code", "pos", "noun", "plural", "noun.phrase", "verb.usually.participle",
"transitive.verb", "intransitive.verb", "adjective", "adverb",
"conjunction", "preposition", "interjection", "pronoun", "definite.article",
"indefinite.article", "nominative"), row.names = c(NA, 6L), class = "data.frame")
write.table(DF2, file = "mobyPOS.csv", sep = " ", col.names = TRUE,qmethod = "double")
Error message I got:
> write.table(DF2, file = "mobyPOS.csv", sep = " ", col.names = TRUE,qmethod = "double")
Error in write.table(x, file, nrow(x), p, rnames, sep, eol, na, dec, as.integer(quote), :
unimplemented type 'list' in 'EncodeElement'
Try
Note that you don’t have to use the extension “Rdata”, but it or “RData” seem to be the convention.
You can then load the data back in using
Note that this is different from reading an external file format where you would normally do something like
With the
loadcommand, it loads the object directly so that after you execute theloadcommand, yourDF2object will be there.