Skip to content

corpus() gives an error for tm VCorpus with single document #445

Description

@a-valyaev

Hi all.

this code

require(tm)
require(quanteda)

df <- data.frame(c(1, 2), c("f", "s"))
# df <- data.frame(c(1), c("f"))
names(df) <- c("id", "value")

map <- list(id = "id", content = "value")
reader <- readTabular(mapping = map)
crp <- VCorpus(DataframeSource(df),  readerControl = list(reader = reader))

corpus(crp)

gives no error.

however for uncommented line df <- data.frame(c(1), c("f")) it gives following error:

"Error in as.data.frame.matrix(do.call(rbind, (lapply(x$content, "[[", :
row names must be 'character' or 'integer', not 'logical'"

i'm quite new to R but as i understand the reason is row.names = FALSE in

as.data.frame(do.call(rbind, (lapply(x$content, "[[", "meta"))),
                           stringsAsFactors = FALSE, row.names = FALSE)

call in 'corpus.R'.


packageVersion("tm") -> '0.6.2'
packageVersion("quanteda") -> '0.9.8.5'
packageVersion("base") -> '3.3.2'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions