[R] Plot numeric and categorical variable
Uwe Ligges
ligges at statistik.tu-dortmund.de
Tue Dec 6 14:19:12 CET 2011
On 05.12.2011 23:22, Juliet Ndukum wrote:
> My data consists of numeric (yy) and categorical (xx) variables, as shown below.
>> xx = c(rep("C", 5), rep("D",5))> xx [1] "C" "C" "C" "C" "C" "D" "D" "D" "D" "D"> yy = rnorm(10, 0, 4)> yy [1] 2.7219346 -3.7142481 6.8716534 -0.9352463 0.4901249 3.8113247 [7] -2.6602041 1.7714471 4.7298233 0.8848188
>> xx1 = as.integer(as.factor(xx))> plot(xx1, yy, ylim = c(-13.5, 4), col="blue")
> I have attached the plot above as plot1
> I wish to generate a scatter plot of the data such that instead of 1 it prints C, and instead of 2, it prints D on the x- axis (see plot1 attached).
> How could I possibly go about this, let me know. Any help will be greatly appreciated.
> Thanks in advance for your help,JN
Sounds like homework?!
Anyway, see ?par and ?axis to answer your question directly or ?boxplot
more implicitly...
Best,
Uwe Ligges
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> ______________________________________________
> R-help at 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.
More information about the R-help
mailing list