Displaying 2 results from an estimated 2 matches for "hills2000".
2005 Feb 27
1
subsetting data set dimenion problem
(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 ar...
2005 Feb 28
0
Re: R-help Digest, Vol 24, Issue 28
You've omitted a comma. races2000 is a data frame,
which for purposes of extracting rows behaves like
a 2-dimenional object. The following works fine:
hills2000 <- races2000[races2000$type == 'hill', ]
Additionally, you might like to ponder
> type <- races2000[names(races2000)=="type"]
> type[1:4]
Error in "[.data.frame"(type, 1:4) : undefined columns selected
> length(type) # type is...