1
 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

kcm
  • 200
  • 3
  • 13

1 Answers1

2

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.

MeetMrMet
  • 1,349
  • 8
  • 14
  • Thank you now i can select my desired column , so how can I pass it and take average of the my columns ?i have to use the mutate function ? – kcm Aug 04 '17 at 19:22
  • 1
    You probably want `summarize`. Take a look at the `dplyr` documentation and vignette https://cran.r-project.org/web/packages/dplyr/vignettes/dplyr.html – MeetMrMet Aug 04 '17 at 19:29