Skip to content
Prev 343543 / 398506 Next

Unexpected behavior when giving a value to a new variable based on the value of another variable

On Fri, Aug 29, 2014 at 3:53 AM, Angel Rodriguez
<angel.rodriguez at matiainstituto.net> wrote:
<snip>
<snip>
That is unusual, but appears to be documented in a section from

?`[`

<quote>
Character indices

Character indices can in some circumstances be partially matched (see
pmatch) to the names or dimnames of the object being subsetted (but
never for subassignment). Unlike S (Becker et al p. 358)), R never
uses partial matching when extracting by [, and partial matching is
not by default used by [[ (see argument exact).

Thus the default behaviour is to use partial matching only when
extracting from recursive objects (except environments) by $. Even in
that case, warnings can be switched on by
options(warnPartialMatchDollar = TRUE).

Neither empty ("") nor NA indices match any names, not even empty nor
missing names. If any object has no names or appropriate dimnames,
they are taken as all "" and so match nothing.
</quote>

Note the commend about "partial matching" in the middle paragraph in
the quote above.