Import individual functions for pairwise_count rather than the entire data.table library. This should remove start up warning messages with namespace conflicts between dplyr and data.table
This commit is contained in:
Martin Chan 2021-01-06 10:49:46 +00:00
Родитель fa9db7b199
Коммит e9a60a8c90
3 изменённых файлов: 21 добавлений и 4 удалений

Просмотреть файл

@ -154,7 +154,6 @@ export(workpatterns_rank)
export(wrap)
import(DT)
import(Information)
import(data.table)
import(dplyr)
import(ggplot2)
import(ggraph)
@ -165,6 +164,8 @@ import(tidyselect)
importFrom(data.table,"%between%")
importFrom(data.table,"%like%")
importFrom(data.table,":=")
importFrom(data.table,as.data.table)
importFrom(data.table,rbindlist)
importFrom(dplyr,`%>%`)
importFrom(dplyr,mutate_if)
importFrom(grDevices,rainbow)

Просмотреть файл

@ -5,16 +5,25 @@
#' within `tm_cooc()`.
#'
#' @param data Data frame output from `tm_clean()`.
#' @param id String to represent the id variable. Defaults to "word".
#' @param id String to represent the id variable. Defaults to "line".
#' @param word String to represent the word variable. Defaults to "word".
#'
#' @import data.table
#' @importFrom data.table ":=" "%like%" "%between%" rbindlist as.data.table
#'
#' @examples
#' td <- data.frame(line = c(1, 1, 2, 2),
#' word = c("work", "meeting", "catch", "up"))
#'
#' pairwise_count(td, id = "line", word = "word")
#'
#' @export
pairwise_count <- function(data,
id = "line",
word = "word"){
# Make sure data.table knows we know we're using it
.datatable.aware = TRUE
data <-
data %>%
dplyr::rename(word := !!sym(word),

Просмотреть файл

@ -9,7 +9,7 @@ pairwise_count(data, id = "line", word = "word")
\arguments{
\item{data}{Data frame output from \code{tm_clean()}.}
\item{id}{String to represent the id variable. Defaults to "word".}
\item{id}{String to represent the id variable. Defaults to "line".}
\item{word}{String to represent the word variable. Defaults to "word".}
}
@ -18,3 +18,10 @@ This is a \strong{data.table} implementation that mimics the output of
\code{widyr::pairwise_count()} to reduce package dependency. This is used internally
within \code{tm_cooc()}.
}
\examples{
td <- data.frame(line = c(1, 1, 2, 2),
word = c("work", "meeting", "catch", "up"))
pairwise_count(td, id = "line", word = "word")
}