[R] x-axis value in boxplot

David Winsemius dwinsemius at comcast.net
Wed Dec 25 16:32:56 CET 2013


On Dec 24, 2013, at 9:02 PM, Kochikkaran Musammilu wrote:

> Hai,
> 
> I
> am new to „R‰ software. 
> 
> I have a doubt, while doing analysis,
> keeping the x axis value as year, in graphical representation (ie, in
> boxplot) the values comes as "X2005", and "X2006"
> and so on in x axis. How to keep "2005", "2006"
> as x axis value instead of "X2005" and "X2006".
> In gist, there comes a prefix "X" before the numeric value
> of X axis variables. How to solve this problem?
> 
> If any suggestions/guidance, please feel free to write <musammilu at hotmail.com>.  Kindly give me the "R" command to get rid of above problem!
> 

`boxplot` has a names argument. If you are passing a dataframe with a 'grp' variable to boxplot.formula, then try:
     boxplot( ... , names = sub("^X", "" dfrm$grp), ...)

See ?regex and ?sub

If this does not address your specific problem, then you would need to be .... more specific.

-- 
David Winsemius
Alameda, CA, USA



More information about the R-help mailing list