[R] Why can't I access this type?

Henric Winell nilsson.henric at gmail.com
Fri Mar 27 13:53:28 CET 2015


On 2015-03-27 09:19, Patrick Connolly wrote:

> [...]
>
> On Sun, 22-Mar-2015 at 08:06AM -0800, John Kane wrote:
>
> |> Well, first off, you have no variable called "Name".  You have lost
> |> the state names as they are rownames in the matrix state.x77 and
> |> not a variable.
>
> If you did this:
>
>> all.states  <- within(as.data.frame(state.x77), Name <- rownames(state.x77))
> instead of
>> all.states  <- within(as.data.frame(state.x77), state <- rownames(state.x77))

Alternatively, since 'data.frame()' coerces internally, one could do

all.states <- data.frame(state.x77, Name = rownames(state.x77))


Henric Winell



>
> then this would worka;
>> cold.states <- all.states[all.states$Frost > 150, c("Name", "Frost")]
>
> Modify the above to match where my guess at what you tried is in error.
>
>
> HTH
>



More information about the R-help mailing list