n <- as.name ("[<-.factor")
`[<-.factor`
> eval (n)
function (x, i, value)
{
    lx <- levels(x)
    cx <- oldClass(x)
    if (is.factor(value))
        value <- levels(value)[value]
    m <- match(value, lx)
    if (any(is.na(m) & !is.na(value)))
        warning("invalid factor level, NAs generated")
## here, let m revert to original value to allow temporary storage in different type (probably character)
## change storage back to 'normal' factor using "match (unclass (x), levels (x))"
    class(x) <- NULL
    if (missing(i))
        x[] <- m
    else x[i] <- m
    attr(x, "levels") <- lx
    class(x) <- cx
    x
}
<environment: namespace:base>
