A question about list

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

A question about list

ufuk beyaztas
This post was updated on .
CONTENTS DELETED
The author has deleted this message.
Reply | Threaded
Open this post in threaded view
|

Re: A question about list

"Dénes TÓTH"

?unlist

quantile(unlist(data))


> Hi dear all,
>
> It may be a simple question, i have a list output with different number of
> elements as following;
>
> [[1]]
>  [1]  0.86801402 -0.82974691  0.39746666 -0.98566707 -4.96576856
> -1.32056754
>  [7] -5.54093319 -0.07600462 -1.34457280 -1.04080125  1.62843297
> -0.20473912
> [13]  0.30659907  2.66908117  2.53791837  0.53788013 -0.57463077
> 0.27708874
> [19] -2.94233200  1.54565643 -6.83694100  7.21556266 -3.14823536
> -1.34590796
> [25]  0.78660855  5.53692735  1.22511890  7.65249980 -0.43008997
> -0.10536125
>
> [[2]]
>  [1] -2.80332826  0.54414548  4.38232256 -1.38407653 -1.59241491
> -1.35509664
>  [7]  1.04806755 -0.27685465 -1.36671548 -3.16649719  2.17194692
> -3.49404253
> [13]  4.69102017  2.78297615  0.34565006  1.05954751  1.78836097
> -0.80393182
> [19]  3.74315304  1.17427902  1.62354686  0.53186688 -6.56519965
> -3.39045485
> [25]  0.01043676 -0.18857654 -0.57070351 -0.06135564  6.92331269
> -1.46544614
> [31] -1.65309767
>
> [[3]]
>  [1]  4.1923546  0.6319591 -0.8568113 -3.3115788 -2.4166481 -1.1543074
>  [7] -0.9333245  0.2632038 -0.6909956 -3.1008763 -2.9557687  1.5382464
> [13]  1.2713290  6.6527302  1.0433603 -0.9916190 -2.7724673 -1.6554250
> [19]  1.8023591 -1.5101793  1.2604704 -0.2853326 -2.4312827 -0.4731487
> [25]  3.5061061  1.7392190  1.5493419 -0.7203778 -0.6995221  2.7686406
> [31]  6.1813364 -1.8665294
>
> I want to compute the percentile of all of 94 elements, i tried
> quantile(data) but i got an error like
> Error in sort.list(x, partial = unique(c(lo, hi))) :
>   'x' must be atomic for 'sort.list'
> Have you called 'sort' on a list?
> Can some one help me abouth this ?
> Thanks for any idea...
>
> --
> View this message in context:
> http://r.789695.n4.nabble.com/A-question-about-list-tp3385711p3385711.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> [hidden email] 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.
>

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: A question about list

jholtman
In reply to this post by ufuk beyaztas
use 'unlist'

> x <- list(1:10, 20:27, 30:50)
> x
[[1]]
 [1]  1  2  3  4  5  6  7  8  9 10

[[2]]
[1] 20 21 22 23 24 25 26 27

[[3]]
 [1] 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50

> quantile(unlist(x))
  0%  25%  50%  75% 100%
 1.0 15.0 31.0 40.5 50.0
>


On Thu, Mar 17, 2011 at 5:44 PM, ufuk beyaztas <[hidden email]> wrote:

> Hi dear all,
>
> It may be a simple question, i have a list output with different number of
> elements as following;
>
> [[1]]
>  [1]  0.86801402 -0.82974691  0.39746666 -0.98566707 -4.96576856 -1.32056754
>  [7] -5.54093319 -0.07600462 -1.34457280 -1.04080125  1.62843297 -0.20473912
> [13]  0.30659907  2.66908117  2.53791837  0.53788013 -0.57463077  0.27708874
> [19] -2.94233200  1.54565643 -6.83694100  7.21556266 -3.14823536 -1.34590796
> [25]  0.78660855  5.53692735  1.22511890  7.65249980 -0.43008997 -0.10536125
>
> [[2]]
>  [1] -2.80332826  0.54414548  4.38232256 -1.38407653 -1.59241491 -1.35509664
>  [7]  1.04806755 -0.27685465 -1.36671548 -3.16649719  2.17194692 -3.49404253
> [13]  4.69102017  2.78297615  0.34565006  1.05954751  1.78836097 -0.80393182
> [19]  3.74315304  1.17427902  1.62354686  0.53186688 -6.56519965 -3.39045485
> [25]  0.01043676 -0.18857654 -0.57070351 -0.06135564  6.92331269 -1.46544614
> [31] -1.65309767
>
> [[3]]
>  [1]  4.1923546  0.6319591 -0.8568113 -3.3115788 -2.4166481 -1.1543074
>  [7] -0.9333245  0.2632038 -0.6909956 -3.1008763 -2.9557687  1.5382464
> [13]  1.2713290  6.6527302  1.0433603 -0.9916190 -2.7724673 -1.6554250
> [19]  1.8023591 -1.5101793  1.2604704 -0.2853326 -2.4312827 -0.4731487
> [25]  3.5061061  1.7392190  1.5493419 -0.7203778 -0.6995221  2.7686406
> [31]  6.1813364 -1.8665294
>
> I want to compute the percentile of all of 94 elements, i tried
> quantile(data) but i got an error like
> Error in sort.list(x, partial = unique(c(lo, hi))) :
>  'x' must be atomic for 'sort.list'
> Have you called 'sort' on a list?
> Can some one help me abouth this ?
> Thanks for any idea...
>
> --
> View this message in context: http://r.789695.n4.nabble.com/A-question-about-list-tp3385711p3385711.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> [hidden email] 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.
>



--
Jim Holtman
Data Munger Guru

What is the problem that you are trying to solve?

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: A question about list

David Winsemius
In reply to this post by ufuk beyaztas

On Mar 17, 2011, at 5:44 PM, ufuk beyaztas wrote:

> Hi dear all,
>
> It may be a simple question, i have a list output with different  
> number of
> elements as following;
>
> [[1]]
> [1]  0.86801402 -0.82974691  0.39746666 -0.98566707 -4.96576856  
> -1.32056754
> [7] -5.54093319 -0.07600462 -1.34457280 -1.04080125  1.62843297  
> -0.20473912
> [13]  0.30659907  2.66908117  2.53791837  0.53788013 -0.57463077  
> 0.27708874
> [19] -2.94233200  1.54565643 -6.83694100  7.21556266 -3.14823536  
> -1.34590796
> [25]  0.78660855  5.53692735  1.22511890  7.65249980 -0.43008997  
> -0.10536125
>
> [[2]]
> [1] -2.80332826  0.54414548  4.38232256 -1.38407653 -1.59241491  
> -1.35509664
> [7]  1.04806755 -0.27685465 -1.36671548 -3.16649719  2.17194692  
> -3.49404253
> [13]  4.69102017  2.78297615  0.34565006  1.05954751  1.78836097  
> -0.80393182
> [19]  3.74315304  1.17427902  1.62354686  0.53186688 -6.56519965  
> -3.39045485
> [25]  0.01043676 -0.18857654 -0.57070351 -0.06135564  6.92331269  
> -1.46544614
> [31] -1.65309767
>
> [[3]]
> [1]  4.1923546  0.6319591 -0.8568113 -3.3115788 -2.4166481 -1.1543074
> [7] -0.9333245  0.2632038 -0.6909956 -3.1008763 -2.9557687  1.5382464
> [13]  1.2713290  6.6527302  1.0433603 -0.9916190 -2.7724673 -1.6554250
> [19]  1.8023591 -1.5101793  1.2604704 -0.2853326 -2.4312827 -0.4731487
> [25]  3.5061061  1.7392190  1.5493419 -0.7203778 -0.6995221  2.7686406
> [31]  6.1813364 -1.8665294
>
> I want to compute the percentile of all of 94 elements, i tried
> quantile(data) but i got an error like
> Error in sort.list(x, partial = unique(c(lo, hi))) :
>  'x' must be atomic for 'sort.list'
> Have you called 'sort' on a list?
> Can some one help me abouth this ?
> Thanks for any idea...

I don't know if quantile has a default for probs but if it does then  
try:

quantile( unlist(mylist) )   # untested.

--

David Winsemius, MD
West Hartford, CT

______________________________________________
[hidden email] 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.