[R] exteremely confused (simple question)

Charles Annis, P.E. Charles.Annis at StatisticalEngineering.com
Tue Oct 31 01:58:34 CET 2006


You need to tell R that you mean Growth, the column in your data.frame.
Otherwise R is looking for an external criterion named Growth.  Try this:

df[df$Growth<0.5,]

That means choose all columns for which df$Growth has a row value < 0.5

> df[df$Growth<0.5,]
  ID    K    Surv    Growth Class
1  1 4808 0.86212 0.0066964     S
3  3 2084 0.93579 0.4407900     S




Charles Annis, P.E.

Charles.Annis at StatisticalEngineering.com
phone: 561-352-9699
eFax:  614-455-3265
http://www.StatisticalEngineering.com
 

-----Original Message-----
From: r-help-bounces at stat.math.ethz.ch
[mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of Chris Fonnesbeck
Sent: Monday, October 30, 2006 7:48 PM
To: r-help at stat.math.ethz.ch
Subject: [R] exteremely confused (simple question)

I thought I knew how to use data frames, but apparently not. I have
created a data frame, and named the columns:

> df
         K    Surv     Growth Class
1     4808 0.86212 0.00669640     S
2     2430 0.98038 1.30540000     S
3     2084 0.93579 0.44079000     S
4     2600 0.95394 2.03680000     S
5     2143 0.96112 1.78330000     S
6     4722 0.96682 6.36850000     S
7     2639 0.94464 0.81887000     S
8     4906 0.96520 3.10040000     S
9     1016 0.98993 1.69870000     S
10     973 0.98137 1.46750000     S
... etc.


However, when I try to index a subset of this data frame, I get an error:

> df[Growth<0.5]
Error in "[.data.frame"(df, Growth < 0.5) :
	object "Growth" not found

Why on earth is it looking for a "Growth" object, when it is a column
name in the data frame??

Extremely confused,
-- 
Chris Fonnesbeck + Atlanta, GA + http://trichech.us

______________________________________________
R-help at stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list