Getting error "can't subset columns that don't exist. Location 2 doesn't exist. There are only 1 column" with interflex package

Hello! I am trying to run the following using the interflex package:

interflex(estimator = "raw", Y = "has_chapter", D = "share_sc_ten", X = "share_white", data = df_1890v2, treat.type="continuous", Ylabel = "Outcome", Dlabel = "Treatment", Xlabel="Moderator", = TRUE, show.grid = FALSE, na.rm=TRUE)

And every time I run this I get the following error message. I have been very stuck on what to do here because these columns do exist in my data...? Thank you so much in advance.

Error: Can't subset columns that don't exist.
x Location 2 doesn't exist.
:information_source: There are only 1 column.


  1. interflex::interflex(...)
  2. base::sort.default(unique(data[, Y]))
  3. tibble:::[.tbl_df(x, order(x, na.last = na.last, decreasing = decreasing))
  4. tibble:::vectbl_as_col_location(...)
  5. vctrs::vec_as_location(j, n, names)
  6. vctrs:::stop_subscript_oob(...)
  7. vctrs:::stop_subscript(...)

Welcome to the community.
I am not familiar with interflex package. Two things you can check

  1. Make sure df_1890v2 is a dataframe (using command class(df_1890v2)) and it has at least 3 columns, "has_chapter", "share_sc_ten", "share_white" (usng command names(df_1890v2))
  2. For estimator, you use the option "raw". But, the package manual says, it can be one of the following: "linear", "binning", "kernel" or "gam"
    You may consider presenting reproducible example by following FAQ: How to do a minimal reproducible example ( reprex ) for beginners . It will help people to think and solve the probelm efficiently.
1 Like

Thank you so much! Yes it was something silly - namely df_1890v2 needed to be converted to a dataframe and then everything worked. Thank you again.

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.