Hi Colin, You should always check the help for your function: ?range says: range(..., na.rm = FALSE)
Arguments: ...: any ‘numeric’ or character objects. na.rm: logical, indicating if ‘NA’'s should be omitted. So for example: > x <- c(1, 2, NA, 3) > range(x) [1] NA NA > range(x, na.rm=TRUE) [1] 1 3 Sarah On Wed, Feb 1, 2012 at 7:48 PM, Colin Wahl <biow...@gmail.com> wrote: > Hello, > I'm using range do define boundaries for a linear model, so the line I > graph is only graphed for the range of data. There are NAs in the > data, but I dont remember this being a problem before. I typed > na.action=na.omit anyway, which has usually solved any NA issues in > the past. Any idea why R cant do vector functions for these data? > Solution? > > Thanks, > Colin Wahl > M.S. Biology candidate > Western Washington University > > fit<-lm(sandcomb ~ CCEC25) > z<-predict(fit, data.frame(CCEC25=range(CCEC25))) > lines(range(CCEC25), z, lty=2, lwd=0.75, col="grey51") > > >> is.vector(CCEC25) > [1] TRUE > >> is.numeric(CCEC25) > [1] TRUE > >> range(CCEC25) > [1] NA NA > >> CCEC25 > [1] 375.8 8769.0 NA 4197.0 NA 36880.0 4167.0 13100.0 3694.0 > [10] 51420.0 30660.0 30850.0 4076.0 NA 59450.0 16050.0 NA 65480.0 > [19] 2101.0 16390.0 5968.0 11330.0 9112.0 8326.0 > >> sessionInfo() > R version 2.14.1 (2011-12-22) > Platform: i386-apple-darwin9.8.0/i386 (32-bit) > > locale: > [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8 > > attached base packages: > [1] stats graphics grDevices utils datasets methods base > > loaded via a namespace (and not attached): > [1] grid_2.14.1 lattice_0.20-0 lme4_0.999375-42 Matrix_1.0-2 > [5] nlme_3.1-102 stats4_2.14.1 tools_2.14.1 > -- Sarah Goslee http://www.functionaldiversity.org ______________________________________________ R-help@r-project.org 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.