user6291
user6291

Reputation: 541

Plotting characters in R

I am trying to make a scatter plot in R where the points that are being plotted correspond to numbers.

x = 1:20
y = 1:20
plot(x,y,pch=as.character(1:20))

However, for all the numbers that have two digits, only the first digit gets plotted. How can I make it so that 10,11,...,20 get plotted instead of 1,1,...,2?

Upvotes: 0

Views: 185

Answers (1)

Alex Thompson
Alex Thompson

Reputation: 506

the text command should do it for you.

x = 1:20
y = 1:20
plot(x,y,type = "n")
text(x, y, labels = 1:20)

Upvotes: 3

Related Questions