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

Patrick Connolly p_connolly at slingshot.co.nz
Fri Mar 27 09:19:26 CET 2015


On Thu, 26-Mar-2015 at 04:58PM -0400, yoursurrogategod at gmail.com wrote:

[...]
|>  I agree with you on the indexing approach.  But even after using
|> within, I still get the same error.  >

You leave us to guess just what you tried, but if you did this:

> all.states  <- within(as.data.frame(state.x77), state <- rownames(state.x77))
and then again did this:

> cold.states <- all.states[all.states$Frost > 150, c("Name", "Frost")]

of course it will give the same error, because as you haven't
addressed the problem as you've been told

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))

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

-- 
~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.   
   ___    Patrick Connolly   
 {~._.~}                   Great minds discuss ideas    
 _( Y )_  	         Average minds discuss events 
(:_~*~_:)                  Small minds discuss people  
 (_)-(_)  	                      ..... Eleanor Roosevelt
	  
~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.



More information about the R-help mailing list