Skip to content

problem subsetting data.frame in R version 2.15.2 for Windows

7 messages · Borja ., Rui Barradas, Pierrick Bruneau +3 more

#
Hello,

Inline.

Em 20-03-2013 22:17, Borja . escreveu:
Because what you understand is wrong. There is no object 'a'. The error 
message is very clear. What you have is an element of the data.frame 
named 'a', that can be accessed like data$a or data[["a"]].
Use the first way of subsetting the data.frame.

Also, 'data' is a bad name for an object, it already is a function name.


Hope this helps,

Rui Barradas

  Instead I get:
#
On Mar 21, 2013, at 7:39, Pierrick Bruneau <pbruneau at gmail.com> wrote:

            
No -- bad idea -- dangerous -- confusing statefulness, etc. (See explanations in the archives as to why)
Try instead 

with(dat, dat[a > 0, ])

for a cleaner option. 

MW
#
Hi

in interactive sessions it is convenient way to call data frame columns and repeatedly use them in calculations. 
You just have to be careful with some functions as they can be useful but dangerous.

rm(something) removes an object from environment without warning.

It is usually not a fault of a program, when something gets wrong.

Regards
Petr