[R] Plot Legend

RMSOPS ricardosousa2000 at clix.pt
Mon Oct 24 12:21:32 CEST 2011

Good Afternoon,

I am inexperienced in data visualization R. so I wonder if someone can help
I am using the generic database mtcars.
I would like to change the chart plot, instead of appearing the name of the
medicine, I wanted a symbol in the chart drugX arise for example in a yellow
circle, and so for the rest of the drugs.

I am using the following code.

    Age Sex     BP Cholesterol       Na        K  Drug
1    23   F   HIGH        HIGH 0.792535 0.031258 drugY
2    47   M    LOW        HIGH 0.739309 0.056468 drugC
3    47   M    LOW        HIGH 0.697269 0.068944 drugC
4    28   F NORMAL        HIGH 0.563682 0.072289 drugX
5    61   F    LOW        HIGH 0.559294 0.030998 drugY
6    22   F NORMAL        HIGH 0.676901 0.078647 drugX
7    49   F NORMAL        HIGH 0.789637 0.048518 drugY
8    41   M    LOW        HIGH 0.766635 0.069461 drugC
9    60   M NORMAL        HIGH 0.777205 0.051230 drugY
10   43   M    LOW      NORMAL 0.526102 0.027164 drugY
11   47   F    LOW        HIGH 0.896056 0.076147 drugC

plot(dataset$Na, dataset$K, main="Na vs K", 
   xlab="Na", ylab="K", pch=20, col="blue")
 text(dataset$Na,dataset$K,dataset$Drug, cex=0.6, pos=4, col="red")

The idea is that instead of writing the name had to be a legend and symbol
was designed in a different color for each drug


View this message in context: http://r.789695.n4.nabble.com/Plot-Legend-tp3932687p3932687.html
Sent from the R help mailing list archive at Nabble.com.

More information about the R-help mailing list