Thanks once again jorge. Regarding your previous reply, i got 50 warnings. Here is what I am trying to do
xx<-0.5*(-359.5:359.5) yy<- 0.5*(-89.75:89.75) x <- xx y <- yy dat1<-matrix(apply(expand.grid(x = y, y = x), 1, function(r) paste0("(", r[1], ",", r[2], ")")), ncol = length(x)) dat<-noquote(dat1) library(maps) library(mapdata) map('worldHires') matpoints(t(dat), type = 'l') Thanks, Eliza From: jorgeivanve...@gmail.com Date: Sat, 22 Mar 2014 22:44:39 +1100 Subject: Re: [R] plotting vectors of different lengths To: eliza_bo...@hotmail.com CC: r-help@r-project.org You are welcome, Eliza. If I understand correctly, the following will do: x <- 1:8y <- 1:5 matrix(apply(expand.grid(x = y, y = x), 1, function(r) paste0("(", r[1], ",", r[2], ")")), ncol = length(x)) Best, Jorge.- On Sat, Mar 22, 2014 at 10:37 PM, eliza botto <eliza_bo...@hotmail.com> wrote: Thankyou very much jorge. It would a great favor if i may know how to go from x=1,2,3,4,5,6,7,8 and y=1,2,3,4,5 TO 1 2 3 4 5 6 7 8 1 (1,1) (1,2) (1,3) (1,4) (1,5) (1,6) (1,7) (1,8) 2 (2,1) (2,2) (2,3) (2,4) (2,5) (2,6) (2,7) (2,8) 3 (3,1) (3,2) (3,3) (3,4) (3,5) (3,6) (3,7) (3,8) 4 (4,1) (4,2) (4,3) (4,4) (4,5) (4,6) (4,7) (4,8) 5 (5,1) (5,2) (5,3) (5,4) (5,5) (5,6) (5,7) (5,8) Thnakyou very in advance Eliza From: jorgeivanve...@gmail.com Date: Sat, 22 Mar 2014 22:26:01 +1100 Subject: Re: [R] plotting vectors of different lengths To: eliza_bo...@hotmail.com CC: r-help@r-project.org Hi Eliza, Perhaps the following? matpoints(t(dat), type = 'l') HTH,Jorge.- On Sat, Mar 22, 2014 at 10:18 PM, eliza botto <eliza_bo...@hotmail.com> wrote: Dear useRs, I have two column vectors of different lengths say x=1,2,3,4,5,6,7,8 and y=1,2,3,4,5. I wanted to plot them by using "points()" command over an already existed image but got an error, "Error in xy.coords(x, y) : 'x' and 'y' lengths differ".What i actually wanted to do was to plot the points in the following format. dat <- read.table(text=" 1 2 3 4 5 6 7 8 1 (1,1) (1,2) (1,3) (1,4) (1,5) (1,6) (1,7) (1,8) 2 (1,1) (1,2) (1,3) (1,4) (1,5) (1,6) (1,7) (1,8) 3 (1,1) (1,2) (1,3) (1,4) (1,5) (1,6) (1,7) (1,8) 4 (1,1) (1,2) (1,3) (1,4) (1,5) (1,6) (1,7) (1,8) 5 (1,1) (1,2) (1,3) (1,4) (1,5) (1,6) (1,7) (1,8) ",sep="",header=TRUE,stringsAsFactors=FALSE) How can i do it? Thankyou very much indeed in advance. Eliza [[alternative HTML version deleted]] ______________________________________________ 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. [[alternative HTML version deleted]] ______________________________________________ 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.