Re: [R] Why points() is defined specially for a 1 by 2 matrix?
To answer one of your other questions: ggplot (and lattice) is/are very powerful, but base graphics are (a) easier to get your head around and (b) easier to adjust if you don't like the defaults. Changing things just a little bit in ggplot can be difficult (as an example, the answer to your other question about getting rid of grid lines has to do with theme_blank(), something like +options(grid.panel.minor=theme_blank()) [try googling theme_blank for a few examples]) In ggplot2, I'd argue it's harder to change things that you shouldn't need to worry about (e.g. the plot background) but much much easier to create plots that actually reveal the patterns in your data. I am a little biased, however ;) Hadley -- http://had.co.nz/ __ 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.
Re: [R] Why points() is defined specially for a 1 by 2 matrix?
points(x[4,],pch=2)# this is plotted as two points drops what it sees as an unnecessary dimension. Use points(x[4,, drop=FALSE], pch=2) See FAQ 7.5 tmp - matrix(1:2) tmp tmp[,1] tmp[,1,drop=FALSE] __ 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.
Re: [R] Why points() is defined specially for a 1 by 2 matrix?
Peng Yu wrote: On Sun, Oct 18, 2009 at 10:26 PM, Richard M. Heiberger r...@temple.edu wrote: points(x[4,],pch=2)# this is plotted as two points drops what it sees as an unnecessary dimension. Use points(x[4,, drop=FALSE], pch=2) See FAQ 7.5 tmp - matrix(1:2) tmp tmp[,1] tmp[,1,drop=FALSE] Can I specify 'drop' to FALSE by default so that I don't have to specify it explicitly? Not that I know of, but things will be easier with the following idiom: x = cbind(1:4,3:6) plot(x[,1],x[,2],pch=rep(1:2,c(3,1))) even easier if the plot types correspond to a factor variable in a data frame: dat = data.frame(x=1:4,y=3:6,type=factor(c(1,1,1,2))) with(dat,plot(x,y,pch=as.numeric(type))) To answer one of your other questions: ggplot (and lattice) is/are very powerful, but base graphics are (a) easier to get your head around and (b) easier to adjust if you don't like the defaults. Changing things just a little bit in ggplot can be difficult (as an example, the answer to your other question about getting rid of grid lines has to do with theme_blank(), something like +options(grid.panel.minor=theme_blank()) [try googling theme_blank for a few examples]) -- View this message in context: http://www.nabble.com/Why-points%28%29-is-defined-specially-for-a-1-by-2-matrix--tp25952698p25953122.html Sent from the R help mailing list archive at Nabble.com. __ 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.