[R] separate elements of a character vector

2010-10-19 Thread Simon Kiss
Dear colleagues, this seems like an easy problem, and I found some suggestions which I've incorporated in the help list, but I can't quite get it right. I want to add a series of years to a second x-axis category label. I generate them with test and test_2 below, format them with some spacing

Re: [R] separate elements of a character vector

2010-10-19 Thread Joshua Wiley
Dear Simon, I think the main issue is that mtext() is designed to work with a single character string, not a character vector. Here is one approach collapsing using paste with some space: x1-rnorm(500) plot(x1) test-seq(1987, 2002, by=1) test_2-seq(2003, 2006, by=1) mtext(paste(c(test, test_2),

Re: [R] separate elements of a character vector

2010-10-19 Thread Thomas Stewart
You may want to try something like this: x1-rnorm(500) plot(x1) test-seq(1987, 2002, by=1) test_2-seq(2003, 2006, by=1) test-format(c(test, test_2), width=5) xxx-seq(1,500,length=length(test)) axis(1,at=xxx,labels=test,line=1,col=0) You'll need to specify where you want the labels (in this code