Skip to content

Commit

Permalink
id, date and title as first columns
Browse files Browse the repository at this point in the history
  • Loading branch information
JonasRieger committed Jun 12, 2019
1 parent 8797ba9 commit 780085c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
4 changes: 4 additions & 0 deletions R/as.meta.R
Expand Up @@ -47,5 +47,9 @@ as.meta <- function(x, cols = colnames(x), idCol = "id", dateCol = "date", title
colnames(x)[colnames(x) == idCol] <- "id"
colnames(x)[colnames(x) == titleCol] <- "title"

# firstThreeCols = c("id", "date", "title")
# x = x[,match(c(firstThreeCols, setdiff(colnames(x), firstThreeCols)), colnames(x))]
x <- cbind(x[,c("id", "date", "title")], x[,!(colnames(x) %in% c("id", "date", "title"))])

invisible(x)
}
2 changes: 2 additions & 0 deletions tests/testthat/test_as.meta.R
Expand Up @@ -10,4 +10,6 @@ test_that("as.textmeta.corpus", {
meta <- meta[, -1]
expect_true(isMeta(as.meta(meta, dateFormat = "%Y-%m-%d")))

expect_equal(colnames(as.meta(meta))[1:3], c("id", "date", "title"))

})

0 comments on commit 780085c

Please sign in to comment.