[R] a question on list manipulation

David Winsemius dwinsemius at comcast.net
Fri Aug 5 18:38:29 CEST 2011


On Aug 5, 2011, at 12:05 PM, zhenjiang xu wrote:

> Hi R users,
>
> I have a list:
>> x
> $A
> [1] "a"  "b"  "c"
> $B
> [1] "b"  "c"
> $C
> [1] "c"
>
> I want to convert it to a lowercase-to-uppercase list like this:
>> y
> $a
> [1] "A"
> $b
> [1] "A"  "B"
> $c
> [1] "A"  "B"  "C"
>
> In a word, I want to reverse the list names and the elements under
> each list name. Is there any quick way to do that? Thanks

The obvious way would be:

names(lll) <- to.upper(names(lll)
lll <- lapply(lll, to.lower)


(If you had offered code that would construct the list, I would have  
tested it.)
-- 

David Winsemius, MD
West Hartford, CT



More information about the R-help mailing list