I've also changed the f() function, i.e.,

f <- function(x){list(1:max(x[1], 4))}


I hope it'll work now.

Best,
Dimitris

----
Dimitris Rizopoulos
Ph.D. Student
Biostatistical Centre
School of Public Health
Catholic University of Leuven

Address: Kapucijnenvoer 35, Leuven, Belgium
Tel: +32/(0)16/336899
Fax: +32/(0)16/337015
Web: http://www.med.kuleuven.be/biostat/
     http://www.student.kuleuven.be/~m0390867/dimitris.htm



----- Original Message ----- 
From: "Robin Hankin" <[EMAIL PROTECTED]>
To: "Dimitris Rizopoulos" <[EMAIL PROTECTED]>
Cc: "Robin Hankin" <[EMAIL PROTECTED]>; 
<[email protected]>
Sent: Monday, November 21, 2005 9:40 AM
Subject: Re: [R] force apply() to return a list


> Hi Dimitris
>
>
> On 21 Nov 2005, at 08:37, Dimitris Rizopoulos wrote:
>> out <- lapply(apply(a2, 1, f), "[[", 1)
>
>
> thanks for this, but it doesn't quite do what I want:
>
>
> > f <- function(x){1:max(x[1],4)}
> > lapply(apply(cbind(1:5,5:1), 1, f), "[[", 1)
> [[1]]
> [1] 1
>
> [[2]]
> [1] 1
>
> [[3]]
> [1] 1
>
> [[4]]
> [1] 1
>
> [[5]]
> [1] 1
>
> >
>
> I want
>
>> [[1]]
>> [1] 1 2 3 4
>>
>> [[2]]
>> [1] 1 2 3 4
>>
>> [[3]]
>> [1] 1 2 3 4
>>
>> [[4]]
>> [1] 1 2 3 4
>>
>> [[5]]
>> [1] 1 2 3 4 5
>
>
>
> best wishes
>
> Robin
>
>
>
>
> --
> Robin Hankin
> Uncertainty Analyst
> National Oceanography Centre, Southampton
> European Way, Southampton SO14 3ZH, UK
>  tel  023-8059-7743
> 


Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm

______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

Reply via email to