[R] strange list structure question
Charles C. Berry
cberry at tajo.ucsd.edu
Tue Nov 4 03:53:40 CET 2008
On Mon, 3 Nov 2008, markleeds at verizon.net wrote:
> Hi Rolf: it's not what's inside the lapplys that i was interested in which
> probably made my question more confusing. all i was trying to show was that,
>
> in EXAMPLE 1, the name comes back at the top level of the result.
>
> in EXAMPLE 2, i can use the name GGG inside the lapply functon to do whatever
> ( the whatever was just a stupid example which can be disregarded ).
>
> my question is : is it possible to do both: be able to return the name at the
> top level but also mess with the name inside the lapply.
Mark,
Does this idiom help?
mapply( my.fun, names(x), x )
where my.fun takes two args: name.x.i and x.i (say).
HTH,
Chuck
> i'm ccing the list
> again because it's quite clear that my question was ill posed. thanks for
> that enlightenment. I can't show my actual example because it's too
> complicated but essentially i want to be able to return GGG at the top level
> like EXAMPLE 1 does but also use GGG inside the lapply like EXAMPLE 2 does.
> Thanks for telling me that i'm confusing !!!!
>
>
>
>
> On Mon, Nov 3, 2008 at 9:10 PM, Rolf Turner wrote:
>
>> Mark:
>>
>> What the <expletive deleted> are you actually trying to do? Your two
>> applications
>> of lapply() do in effect quite different things. The first gives a list
>> of
>> length 1; the single entry is named ``GGG''; this entry is a list of
>> length 3.
>>
>> The second application gives a list of length 3. Each entry of this list
>> is a vector
>> of length 1. The single entry of each such vector has name ``GGG'' just as
>> you requested.
>>
>> R does what you ask it to do. You have to be clear in your own mind as to
>> just
>> what you're asking.
>>
>> cheers,
>>
>> Rolf
>>
>> ######################################################################
>> Attention:This e-mail message is privileged and confidential. If you are
>> not theintended recipient please delete the message and notify the
>> sender.Any views or opinions presented are solely those of the author.
>>
>> This e-mail has been scanned and cleared by
>> MailMarshalwww.marshalsoftware.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.
>
>
Charles C. Berry (858) 534-2098
Dept of Family/Preventive Medicine
E mailto:cberry at tajo.ucsd.edu UC San Diego
http://famprevmed.ucsd.edu/faculty/cberry/ La Jolla, San Diego 92093-0901
More information about the R-help
mailing list