Re: [R] name returned by lapply

2008-07-21 Thread Tony Plate
If you return the value as named list, you get your answer using unlist(res, recursive=F): res - lapply(1:2, function(i) {val - list(i); names(val) - paste(Hugo, i, sep=_); return(val)}) unlist(res, rec=F) $Hugo_1 [1] 1 $Hugo_2 [1] 2 Antje wrote: Oh true, this would solve the problem

[R] name returned by lapply

2008-07-18 Thread Antje
Hi there, I have a very simple question. If I execute the following code: test - function(x) { name - paste(x,info_within_function) c(1,2,3,4,5) } ret - lapply(1:10, test) , I end up with a list and each entry is just numbered [[1]], [[2]], ... [[10]] How can I force the

Re: [R] name returned by lapply

2008-07-18 Thread Gavin Simpson
On Fri, 2008-07-18 at 13:45 +0200, Antje wrote: Hi there, I have a very simple question. If I execute the following code: test - function(x) { name - paste(x,info_within_function) c(1,2,3,4,5) } Here your test is returning c(1,2,3,4,5), and is doing nothing with name,

Re: [R] name returned by lapply

2008-07-18 Thread Antje
Hi Gavin, thanks a lot for your answer. Maybe I did not explain very well what I want to do and probably chose a bad example. I don't mind spaces or names starting with a number. I could even name it: Hugo1, Hugo2, ... My biggest problem is, that not only the values are calculated/estimated

Re: [R] name returned by lapply

2008-07-18 Thread Gavin Simpson
On Fri, 2008-07-18 at 14:19 +0200, Antje wrote: Hi Gavin, thanks a lot for your answer. Maybe I did not explain very well what I want to do and probably chose a bad example. I don't mind spaces or names starting with a number. I could even name it: Hugo1, Hugo2, ... My biggest

Re: [R] name returned by lapply

2008-07-18 Thread Antje
Thanks a lot for your help! I know that I cannot directly access the list created, I just was not sure if there is any format of the return value which could provide additionally a name for the returned list. I tried to return the values as list with the appropriate name but then I end up

Re: [R] name returned by lapply

2008-07-18 Thread Antje
Oh true, this would solve the problem too :-) Thanks a lot for the suggestions! Antje Martin Morgan schrieb: Antje [EMAIL PROTECTED] writes: Thanks a lot for your help! I know that I cannot directly access the list created, I just was not sure if there is any format of the return value