[R] How can I make a list using aggregate function?

Rui Barradas ruipbarradas at sapo.pt
Thu Jun 28 18:09:49 CEST 2012


Hello,

Your data is a mess, with more columns than column names.
Use

# 20 to 100
dput(head(comb.data, 30)) # paste the output of this in a post.


Anyway, it seems that what you want is (untested)

aggregate(zFEl~sequence, data=comb.data, quantile, probs=c(0.5,0.8,0.9), 
na.rm=T)

Hope this helps,

Rui Barradas

Em 28-06-2012 15:10, sureshraj escreveu:
> Hi freind,
>   My data seems to be like , and data frame name is comb.data
> sequence               weight rsat.          zFEl
> 1    CTTTTCTTGTT    4.6   0.00058  -7.452 3.237
> 2    ACTTTGAGGTG    4.1   0.00077  -7.169 3.114
> 3    GTCTTGAACTC    4.8   0.00055  -7.506 3.260
> 4   GCTTTGAAGAA    6.6   0.00019  -8.568 3.721
> 5    GCTTTCAACAT    7.0   0.00014  -8.874 3.854
> 6   TCCTTGTTCAT    3.5   0.00099  -6.918 3.004
>
> So I need to use aggregate function based on sequence
> column(by=list(comb.data$sequence) for zFE column and I should need to store
> those results in lists..so result would be like
>   [[1]]
> CTTTTCTTGTT     2.3758   3.237
> [[2]]
> ACTTTGAGGTG   1.78977  -5.11768684
> [[3]]
>   GTCTTGAACTC    1.987455  1.260
> [[1]]
>   GCTTTGAAGAA  1.019  0.72541
> [[4]]
>   GCTTTCAACAT    0.0423   3.865754
> ...so I made a code like this,,but i am facing some bugs as i mentioned
> before,,could you please help to solve this one??I hope now you understand
> my query...
>
> the code is
> "data <- lapply(comb.data$zFE, function(x)
> aggregate(x,by=list(comb.data[["sequence"]]), quantile,
> probs=c(0.5,0.8,0.9), na.rm=T)) "
>
>
> Thanks,,
>
>
>
> --
> View this message in context: http://r.789695.n4.nabble.com/How-can-I-make-a-list-using-aggregate-function-tp4634714p4634764.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



More information about the R-help mailing list