On Sat, 29 Sep 2001, Winifred Lambert wrote:
> SPlus 2000, Windows 2000
>
> All,
>
> I have done alot of looking the last couple of days and can't seem to
> find a cure to this issue. I have a data frame with 13 columns of
> numeric data (mixture of integer and floating point columns) and 8902
> rows. Some of the data are missing and are designated with NA. I would
> like to stratify the data by value ranges (0-30, 30-60, 60-90, etc) in
> one of the integer columns, named DIR. In the past, I have stratified
> data in this way:
>
> > good.30 <- MyDF$DIR < 30
good.30 <- (MyDF$DIR < 30) & !is.na(MyDF$DIR)
> > MyDF.30 <- MyDF[good.30,]
>
> and have never had a problem. However, I must have always used vectors
> that did not contain NAs. Because of the NAs in DIR, corresponding NAs
> occurred in the logical vector good.30, and the second command above
> produced the following error:
>
> Error in dimnames(x) <- list(rn, dimnames(x)[[2]]): Component 1 of
> dimnames has length 7438, should be 1115.
[That looks like a bug, but I can't reproduce anything like it.]
> To find out how many Fs, Ts and NAs there were in the logical vector, I
> fumbled around with the table command until I figured out to do the
> following:
>
> > table(na.include(as.factor(good.test)))
> FALSE TRUE NA
> 7787 1003 112
>
> I can see that TRUE + NA = 1115, but I can't figure out where the 7438
> came from in the error statement. I manually edited good.30 so that all
> the NAs were Fs and got the desired results. After looking in help at
> various commands and in the Programmers Guide, I cannot find a way to
> create a logical using a numeric vector containing NAs. I am now trying
> to figure out how to automatically change the NAs in the logical to Fs.
>
> Does anyone know of a command that is more succint than creating a
> logical then editing it? I'd also like some advice on how to
> automatically edit the logical vector if you know how to do it. I'm
> currently looking at the if() function. Thanks much for the help.
>
> *************************************************
> Winifred C. Lambert Senior Scientist/Meteorologist
> ENSCO, Inc.
> Aerospace Sciences and Engineering Division
> 1980 N Atlantic Ave, Suite 230
> Cocoa Beach, FL 32931
> VOICE: 321.853.8130 FAX: 321.853.8415
> lambert.winifred@ensco.com
>
> AMU Quarterly Reports are available online:
> http://science.ksc.nasa.gov/amu/home.html
> *************************************************
>
> ---------------------------------------------------------------------
> This message was distributed by s-news@lists.biostat.wustl.edu. To
> unsubscribe send e-mail to s-news-request@lists.biostat.wustl.edu with
> the BODY of the message: unsubscribe s-news
>
--
Brian D. Ripley, ripley@stats.ox.ac.uk
Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel: +44 1865 272861 (self)
1 South Parks Road, +44 1865 272860 (secr)
Oxford OX1 3TG, UK Fax: +44 1865 272595
|