Error: subscript out of bounds

Not exactly sure what has changed, however I am not receiving this error when my code has run in the past. I've installed older versions of Rtools and continue to get the same error. Below is the part of the code that is causing the error.

Error:
Error in describe[[column$name]][["counts"]][["unique"]] :
subscript out of bounds
In addition: Warning message:
In for (i in (1L:cols)[do]) { :

TraceBack:
11.
get_column_measures(result$column.names, date_CI, result$description) at summaries.R#19
10.
summaries(sales_item, unique_CI = NULL, date_CI = sales_item_columns$date$index) at checkSalesItem.R#19
9.
checkSalesItem(sales_items_file_params, file, sales_item_columns,
product) at run_profiling_si.R#79
8.
eval(ei, envir)
7.
eval(ei, envir)
6.
withVisible(eval(ei, envir))
5.
source(paste(profilingScriptLocation, "/run_profiling_si.R",
sep = "")) at profiling_sales_item.R#59
4.
eval(ei, envir)
3.
eval(ei, envir)
2.
withVisible(eval(ei, envir))
1.
source("C:/Users/*/Desktop//****Profiler v0.3/profiling_sales_item.R") ( is private info)

Script that is breaking:
function (column.names, CI, describe) {
column <- list(name=find_column_by_id(column.names, CI))
if (!is.null(column$name)) {
column$is.missing <- FALSE
column$count <- as.integer(describe[[column$name]][["counts"]][["n"]])
column$missing <- as.integer(describe[[column$name]][["counts"]][["missing"]])
column$unique <- as.integer(describe[[column$name]][["counts"]][["unique"]])

if (is.missing_column(describe, column$name))
  column$is.missing <- TRUE

} else
column$is.missing <- TRUE

column
}

Hi,

Welcome to the RStudio community!

I suggest you make a reprex of the issue, as just posting the error and part of the code is not helping us much here. A reprex consists of the minimal code and data needed to recreate the issue/question you're having. You can find instructions how to build and share one here:

In general, the "out of bounds error" happens when you try to access an index in a list that does not exists (e.g. index is larger than length of list). Look carefully in your code where this might happen, and you should be able to fix it.

myList = list(a = 1, b = 2, c = 3)

#Index 1 exists
myList[[1]]
#> [1] 1

#Index 4 does not exist
myList[[4]]
#> Error in myList[[4]]: subscript out of bounds

Created on 2021-09-21 by the reprex package (v2.0.0)

Hope this helps, otherwise post your reprex and we'll take it from there.

PJ

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.