Skip to content

subset dataframe/list

5 messages · Cecilia Carmo, David Winsemius, Jorge Ivan Velez

#
Hi R-helpers!

I have the following object:
caedois           b1           b2           b3
1       1    0,033120395 -20,29478338 -0,274638864
2       2   -0,040629634  74,54239889 -0,069958424
3       5   -0,001116816   35,2398622  0,214327185
4      10     0,171875
5      14   0,007288399  40,06560548 -0,081828338
6      15   0,027530346  0,969969409  0,102775555

I?ve tried to subset it like this:
but it does nothing

Then I?ve tried:
But I?ve got the following
Warning message:
In Ops.factor(b1, 0) : > not meaningful for factors

So I?ve tried:
Warning message:
In Ops.factor(coeficientes$b1, 0) : > not meaningful for 
factors

  I?ve done
[1] "list"

But I don?t know how to handle it!
Coul anyone help me?
Thanks,

Cec?lia Carmo (Universidade de Aveiro ? Portugal
#
On Jun 1, 2009, at 1:01 PM, Cecilia Carmo wrote:

            
So the b1 variable is a factor. How it got that way is hard to  
determine.
So coeficientes could be just a list or  more likely it is a data.frame.

What happens if you convert b1 to numeric? Try this way:

coeficientes$b1 <- as.numeric( as.character(coeficientes$b1) )

Then try subsetting.

See: http://cran.r-project.org/doc/FAQ/R-FAQ.html#How-do-I-convert-factors-to-numeric_003f
David Winsemius, MD
Heritage Laboratories
West Hartford, CT
#
It doesn't work. b1 was substituted by NA's with this 
message:
Warning message:
NAs introduced by coercion

I will see in the webpage that you mentioned.

Thanks,

Cec?lia

Em Mon, 1 Jun 2009 13:23:12 -0400
  David Winsemius <dwinsemius at comcast.net> escreveu:
#
So now is the time to back up to the beginning and demonstrate how you  
created the coeficientes object. Ideally you would also provide the  
results of:

dput(coeficientes)

or

str(coeficientes)

Subset will only work with dataframes, so if coeficientes is not a  
dataframe, then you will need to come. It would also be a good idea to  
describe what you are trying to get out of this effort.