Hi, Would a specialist of the "point" or "plot" functions try the following: mat<-matrix(c(1.836767,4.025989,0.6396777,0.3764444),ncol=2) plot(mat) points(mat[1,],col="red") ..A lag appears on x for mat [1,1] between the two displays. I wonder if this example may be due to a bug or to the mis-use of a matrix in the plot() points() functions. In case of mise-use which kind can it be? I am working with R 2.0.1 and Windows XP. Cheers, Patrick Giraudoux
You have forgotten drop=FALSE in mat[1,]: take a look at what it produces. See ?Extract for more details. On Mon, 3 Jan 2005, Patrick Giraudoux H wrote:> Would a specialist of the "point" or "plot" functions try the following: > > mat<-matrix(c(1.836767,4.025989,0.6396777,0.3764444),ncol=2) > plot(mat) > points(mat[1,],col="red") > > ..A lag appears on x for mat [1,1] between the two displays. > > I wonder if this example may be due to a bug or to the mis-use of a matrix in > the plot() points() functions. In case of mise-use which kind can it be?Not using a matrix at all! -- Brian D. Ripley, ripley at 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 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595
Patrick Giraudoux H wrote:> Hi, > > Would a specialist of the "point" or "plot" functions try the following: > > mat<-matrix(c(1.836767,4.025989,0.6396777,0.3764444),ncol=2) > plot(mat) > points(mat[1,],col="red") > > ..A lag appears on x for mat [1,1] between the two displays. > > I wonder if this example may be due to a bug or to the mis-use of a > matrix in the plot() points() functions. In case of mise-use which kind > can it be?It's misuse: For a matrix, the first column is interpreted as the x-coordinates, the second one as y-coordinates. For a vector (mat[1,] is a (1D) vector!) plot/points plots the values (as y-coordinates) against their index (1:2 in this case, where 1 is not visible in the plot). You can use points(mat[1,,drop=FALSE], col="red") in order not to drop dimensions, so mat[1,,drop=FASLE] is still a 2-column matrix. Uwe Ligges> I am working with R 2.0.1 and Windows XP. > > Cheers, > > Patrick Giraudoux > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! > http://www.R-project.org/posting-guide.html