Skip to content
Back to formatted view

Raw Message

Message-ID: <CAM_vjukp8TCbOb+vqX+B4osVazcKWuWfcXGDx_gvVLZChuSh9A@mail.gmail.com>
Date: 2011-12-06T13:35:20Z
From: Sarah Goslee
Subject: Plot numeric and categorical variable
In-Reply-To: <4EDE1650.8090601@statistik.tu-dortmund.de>

Not to mention that I answered this exact question only
yesterday.

2011/12/6 Uwe Ligges <ligges at statistik.tu-dortmund.de>:
> 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
>
>
>
>>


-- 
Sarah Goslee
http://www.functionaldiversity.org