Jak spłaszczyć listę list?
Thetm
pakiet rozszerza sięc
tak, jeśli dany zestawPlainTextDocument
s automatycznie tworzy aCorpus
. Niestety wydaje się, że każdyPlainTextDocument
należy podać osobno.
na przykład Jeśli miałbym:
foolist <- list(a, b, c); # where a,b,c are PlainTextDocument objects
Zrobiłbym to, aby uzyskaćCorpus
:
foocorpus <- c(foolist[[1]], foolist[[2]], foolist[[3]]);
Mam listę list'PlainTextDocument
s, który wygląda tak:
> str(sectioned)
List of 154
$ :List of 6
..$ :Classes 'PlainTextDocument', 'TextDocument', 'character' atomic [1:1] Developing assessment models Developing models
.. .. ..- attr(*, "Author")= chr "John Smith"
.. .. ..- attr(*, "DateTimeStamp")= POSIXlt[1:1], format: "2013-04-30 12:03:49"
.. .. ..- attr(*, "Description")= chr(0)
.. .. ..- attr(*, "Heading")= chr "Research Focus"
.. .. ..- attr(*, "ID")= chr(0)
.. .. ..- attr(*, "Language")= chr(0)
.. .. ..- attr(*, "LocalMetaData")=List of 4
.. .. .. ..$ foo : chr "bar"
.. .. .. ..$ classification: chr "Technician"
.. .. .. ..$ team : chr ""
.. .. .. ..$ supervisor : chr "Bill Jones"
.. .. ..- attr(*, "Origin")= chr "Smith-John_e.txt"
#etc., all sublists have 6 elements
Więc, żeby dostać wszystko mojePlainTextDocument
s doCorpus
, to by działało:
sectioned.Corpus <- c(sectioned[[1]][[1]], sectioned[[1]][[2]], ..., sectioned[[154]][[6]])
Czy ktoś może zaproponować łatwiejszy sposób?
ETA:foo<-unlist(foolist, recursive=FALSE)
tworzy płaską listę PlainTextDocuments, która wciąż pozostawia mi problem z podawaniem elementu list po elemencie doc