Hi,

On Thu, Nov 10, 2011 at 1:55 PM, JulioSergio <[email protected]> wrote:
> I'm studying lists and I came to an example where
>
>> L
> $name
> [1] "Fred"
>
> $wife
> [1] "Mary"
>
> $no.children
> [1] 4
>
> $child.ages
> [1] 4 7 9
>
> then following the instructions to extend the list with a new component, I
> executed:
>
>> L[5] <-list(NewName="something")

You've assigned a list to the 5th element of L, not the character
vector you seem to be expecting.

You probably want:
L["NewName"] <- "something"
or one of the many potential variants.

Sarah

> and the new list I got was:
>
>> L
> $name
> [1] "Fred"
>
> $wife
> [1] "Mary"
>
> $no.children
> [1] 4
>
> $child.ages
> [1] 4 7 9
>
> [[5]]
> [1] "something"
>
> Here the 5th element lacks the name "NewName" ... maybe this is a bug. Do you
> have any comments?
>
> Thanks,
>
> Sergio.
>

-- 
Sarah Goslee
http://www.functionaldiversity.org

______________________________________________
[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
and provide commented, minimal, self-contained, reproducible code.

Reply via email to