Error in Newest R Studio for Dataframes larger than 2000 columns

I downloaded a new version of R Studio (2023.03.0) yesterday and am now running into an error. Previous to my download, I did not get an error, however now whenever I try to call a column (using a $) from a large dataframe, I get the following error:

Error in order(typeScores, scores) : argument lengths differ
In addition: Warning message:
In completions$type == .rs.acCompletionTypes$DATAFRAME & !completions$context %in% :
longer object length is not a multiple of shorter object length

The following code (constructed for the post here Error in autocomplete for large dataframes · Issue #13018 · rstudio/rstudio · GitHub by someone else who faced the same error) duplicates the issue:


generate_dataframe <- function(n_rows, n_columns) {
  set.seed(42) # Setting the seed for reproducibility
  random_column_generator <- function(n_rows) {
    col_type <- sample(c("character", "numeric", "boolean", "factor"), 1)
    if (col_type == "character") {
      return(sample(c(LETTERS, NA), n_rows, replace = TRUE))
    } else if (col_type == "numeric") {
      return(sample(c(rnorm(n_rows, mean = 0, sd = 1), NA), n_rows, replace = TRUE))
    } else if (col_type == "boolean") {
      return(sample(c(TRUE, FALSE, NA), n_rows, replace = TRUE))
    } else if (col_type == "factor") {
      values <- sample(c(-1:1, NA), n_rows, replace = TRUE)
      labels <- c("Negative", "Neutral", "Positive")
      return(factor(values, levels = c(-1, 0, 1), labels = labels, exclude = NULL))
  random_string <- function(length) {
    return(paste(sample(c(LETTERS, letters), length, replace = TRUE), collapse = ""))
  df <- data.frame(matrix(ncol = n_columns, nrow = n_rows))
  for (i in 1:n_columns) {
    df[[i]] <- random_column_generator(n_rows)
  colnames(df) <- replicate(n_columns, random_string(sample(1:8, 1)))

# Generate random large dataframe
generated.df <- generate_dataframe(n_rows = 5e4, n_columns = 4e3)

If you type "generated.df$" the error will appear. My question is, why is this error occurring? It doesn't seem to be changing how my code is running--what does it mean? And lastly, is this a bug in the newest R studio?


I am experiencing the same error when calling the $ operator on a large quanteda tokens object. I had not run the code previously but updated to RStudio version 2023.03.1+446 (2023.03.1+446) this morning. I hope it will be resolved soon!

I got the same error message when working with a data frame with >3000 columns with RStudio 2023.03.1-446. But with RStudio 2022.12.0, the same codes won't generate the error message. Hope this problem will be fixed soon.

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.