kcm
kcm

Reputation: 200

Average of Multiple columns in dplyr getting error "must resolve to integer column positions, not a list"

 gene   HSC_7256.bam HSC_6792.bam HSC_7653.bam   HSC_5852

My data frame looks like this i can do that in a normal way such as take out the columns make another data frame average it ,but i want to do that in dplyr and im having a hard time I not sure what is the problem

I doing something like this

HSC<- EPIGENETIC_FACTOR_SEQMONK %>%
    select(EPIGENETIC_FACTOR_SEQMONK,gene)

I get this error

Error: EPIGENETIC_FACTOR_SEQMONK must resolve to integer column positions, not a list

So i have to do this take out all the HSC sample average them

Anyone suggest what am i doing it incorrectly ?that would be helpful

Upvotes: 1

Views: 844

Answers (1)

MeetMrMet
MeetMrMet

Reputation: 1359

The %>% function pulls whatever is to the left of it into the first position of the following function. If your data frame is EPIGENETIC_FACTOR_SEQMONK, then these two statements are equivalent:

HSC <- EPIGENETIC_FACTOR_SEQMONK %>%
   select(gene)

HSC <- select(EPIGENETIC_FACTOR_SEQMONK, gene)

In the first, we are passing EPIGENETIC_FACTOR_SEQMONK into select using %>%, which is generally used in dplyr chains as the first argument in dplyr functions is a data frame.

Upvotes: 2

Related Questions