Skip to content

Commit

Permalink
Merge 09ca7a2 into 0dd13d7
Browse files Browse the repository at this point in the history
  • Loading branch information
kbenoit committed Feb 26, 2019
2 parents 0dd13d7 + 09ca7a2 commit 30d3643
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
8 changes: 7 additions & 1 deletion R/as.textmeta.corpus.R
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,13 @@ as.textmeta.corpus <- function(corpus, cols, dateFormat = "%Y-%m-%d", idCol = "i
length(dateCol) == 1, length(titleCol) == 1, length(textCol) == 1,
length(duplicateAction) == 1)

if(missing(cols)) cols <- colnames(corpus$documents)
# restructure corpus using 1.4.x format
corpus <- list(documents = data.frame(texts = quanteda::texts(corpus),
quanteda::docvars(corpus),
stringsAsFactors = FALSE),
metadata = quanteda::metacorpus(corpus))

if (missing(cols)) cols <- colnames(corpus$documents)
cols <- setdiff(cols, c(idCol, dateCol, titleCol, textCol))

if(!(idCol %in% colnames(corpus$documents))){
Expand Down
4 changes: 0 additions & 4 deletions tests/testthat/test_as.textmeta.corpus.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,4 @@ test_that("as.textmeta.corpus", {

obj <- as.textmeta.corpus(corp)
expect_true(is.textmeta(obj))

corp$documents <- corp$documents[,-1]
obj <- as.textmeta.corpus(corp)
expect_true(is.textmeta(obj))
})
1 change: 1 addition & 0 deletions vignettes/Vignette.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ editor_options:
vignette: >
%\VignetteIndexEntry{Vignette tosca}
%\VignetteEngine{knitr::rmarkdown}
%\VignetteEncoding{UTF-8}
---
\newpage
# Introduction
Expand Down

0 comments on commit 30d3643

Please sign in to comment.