Java Mailing List Archive

http://www.r-help.com/

Home » Home (12/2007) » R Help for Statistical Computing »

[R] subsetting data set dimenion problem

Clint Harshaw

2005-02-27

Replies:

(See DAAG book, p. 173, ex. 3)

I'm a new user of R, and I'm following the DAAG text. I want to create a
subset of the races2000 data frame, but get errors because of a mismatch
of values in some columns:

> library(DAAG)
> attach(races2000)
> hills2000 <- races2000[races2000$type == 'hill']
Error in as.matrix.data.frame(x) : dim<- : dims [product 770] do not
match the length of object [771]

However, if I follow the solution given, and remove redundant columns 1
through 6 and column 11 (which I won't need, since I know they are going
to have the same value), I don't get the error:

> hills2000 <- races2000[races2000$type == 'hill', -c(1:6,11)]
> hills2000
               dist climb    time    timef
Tiso Carnethy       6.00 2500 0.7822222 0.9191667
[...]
Cornalees         5.50  800 0.6183333      NA
[...]

What is causing the error with my original subsetting? I speculated it
was related to the NA values, but there is an NA in the resulting
hills2000, corresponding to the Cornalees hill race.

Thanks,
Clint
--
Clint Harshaw, PhD    
Department of Mathematics
Presbyterian College
Clinton SC 29325

EMail: charshaw@(protected)  
Phone: 864.833.8995
Fax: 864.938.3769
Office: Harrington-Peachtree Rm 412

______________________________________________
R-help@(protected)
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
©2008 r-help.com - Jax Systems, LLC, U.S.A.