[R] selection of outputs from the function

David Winsemius dwinsemius at comcast.net
Fri Dec 24 19:04:50 CET 2010


On Dec 24, 2010, at 12:58 PM, David Winsemius wrote:

>
> On Dec 24, 2010, at 11:56 AM, ufuk beyaztas wrote:
>
>>
>> Hi Dear All,
>> This is a function which contains Covariance Ratio and Likelihood  
>> Distance
>> values (CVRi, LDi). i want to compute the all row's values, that is  
>> run this
>> function for nrow(X) times. The X and Y matrices are;
>>
>> X<- 
>> matrix 
>> (c 
>> (1125,920,835,1000,1150,990,840,650,640,583,570,570,510,555,460,275,510,165,244,79,232,26
snipped example data and code
>>
>>
>> list(ti=ti,ti.star=ti.star,pi=pi,pi.star=pi.star,LDi=LDi,CVRi=CVRi) }
>>
>> obj<-list()
>> for(i in 1:nrow(X)){
>> X<-X
>> Y<-Y
>> out<-theta(X,Y)
>> obj<-c(obj,list(out))}
>> obj
>>
>> Finally i get values...
>> Is there any way to get the outputs as a list or data.frame like
>
> Try this:
>
> do.call(rbind, obj)

If you wanted a dataframe you could also use

do.call(rbind.data.frame, obj)

-- 
David.
>
> -- 
> david.
>>   pi CVRi
>> 1   1    1
>> 2   2    2
>> 3   3    3
>> 4   4    4
>> 5   5    5
>> 6   6    6
>> 7   7    7
>> 8   8    8
>> 9   9    9
>> 10 10   10
>> 11 11   11
>> 12 12   12
>> 13 13   13
>> 14 14   14
>> 15 15   15
>> 16 16   16
>> 17 17   17
>> 18 18   18
>> 19 19   19
>> 20 20   20
>> for all values (pi,pi.star,ti,ti.star,CVRi,LDi)...
>> Thanks so much for any idea !
>> -- 
>> View this message in context: http://r.789695.n4.nabble.com/selection-of-outputs-from-the-function-tp3163361p3163361.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.
>
> David Winsemius, MD
> West Hartford, CT
>
> ______________________________________________
> 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.

David Winsemius, MD
West Hartford, CT



More information about the R-help mailing list