Error in UseMethod("select_") : no applicable method for 'select_' applied to an object of class "character"

Viewed 7422

I am trying to extract some columns from the data which is result of analysis. The data is composed of 592 rows and 20 variables.

When I run the code as below, I got the error message

"Error in UseMethod("select_") : no applicable method for 'select_' applied to an object of class "character" "

unused_cols <- -c(2:9)

pvals_long <- pvals %>%
  map(function(x){
    x <- x %>%
      dplyr::select(unused_cols) %>%
      gather(key = "celltype_pair", value = "pvalue", -interacting_pair)
    x
  })

Thanks in advance,

1 Answers
  1. map is not needed. Mapping on a dataframe means that you are trying to apply your function on each column. However, select expects a dataframe, while in your code it gets a vector. That's what the error is telling you.
  2. unused_cols <- -c(2:9) will not work. Put the -in the call to select.

Try this:

unused_cols <- c(2:9)

pvals_long <- pvals %>%
    select(-unused_cols) %>%
    gather(key = "celltype_pair", value = "pvalue", -interacting_pair)
Related