omarish - 6 months ago 66

R Question

How can I render the value of points in a

`plot`

`plot`

Thank you.

Answer

```
b0 = 2.5; b1 = 2
n = 100
x = rnorm(n, 20, 15)
y = b0 + b1*x + rnorm(n, 0, 15)
plot(x, y)
plot(x, y, type='n')
text(x, y, round(y, 2), cex=0.45)
text(x, y, round(y, 2), cex=0.8)
text(x, y, paste(round(x, 2), round(y, 2), sep=", "), cex=0.8) # for (x, y), but this gets cluttered.
```

Use `cex`

for character size (see help for text). And use `plot(x, y, type='n')`

to set up your window correctly without actually plotting anything.