'How do I interpret error: "Error in intI(j, n = x@Dim[2], dn[[2]], give.dn = FALSE) : invalid character indexing" in R?

I am trying to run this small script in R:

minimumFrequency <- 10

datadtm <- DocumentTermMatrix(datacorpusclean, control=list(bounds = list(global=c(1, Inf
)), weighting = weightBin))

# convert dtm into sparse matrix
datasdtm <- Matrix::sparseMatrix(i = datadtm$i, j = datadtm$j,
                                   x = datadtm$v,
                                   dims = c(datadtm$nrow, datadtm$ncol),
                                   dimnames = dimnames(datadtm))
# calculate co-occurrence counts
coocurrences <- t(datasdtm) %*% datasdtm
# convert into matrix
collocates <- as.matrix(coocurrences)

source("https://slcladal.github.io/rscripts/calculateCoocStatistics.R")

coocTerm <- "selection"

# calculate co-occurence statistics
coocs <- calculateCoocStatistics(coocTerm, datasdtm, measure="LOGLIK")

But in the last row I am getting this error:

Error in intI(j, n = x@Dim[2], dn[[2]], give.dn = FALSE) : invalid character indexing.

I am not an expert in R, could anyone explain me why this happen? What does it exactly mean?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source