I have data in data.frame and I am gonna try pipeline feature of dplyr packages to do few pipeline operation in R. For example, given dataframe objects, first I will do subset, then export as csv files format. I am studying the feature of dplyr packages, so not perfectly understand this. Any help ? Here is the simple reproducible example for simulation:
a <- GRanges(
seqnames=Rle(c("chr1", "chr2", "chr3", "chr4"), c(3, 2, 1, 2)),
ranges=IRanges(seq(1, by=9, len=8), seq(7, by=9, len=8)),
rangeName=letters[seq(1:8)], score=sample(1:20, 8, replace = FALSE))
I do subsetting first:
a %>% subset(pvalue < 1e-4 & pvalue > 1e-9)
then wants to do several pipeline operation by using feature of dplyr:
a %>% subset(pvalue < 1e-4 & pvalue > 1e-9) %>% write.table(x, "foo.csv") %>% as.data.frame(x)
but I have an error when I do second step. If I need to do several pipeline work like result of first is used in the second, how can I proceed this in R by using dplyr packages ? Thanks