# How to achieve r value 1.0 with Linear slope angle 10° in R [closed]

I have been reading about the r value and its purpose, however the below image has altered my understanding(that r value represents Direction and Strength and also Slope Angle).

The Wikipedia image below proves that Slope Angle cannot be determined from the r value at all. My problem is that I cannot seem to produce a scatter plot with a perfect r value 1.0 other than in a 45° angled slope.

Here is some R code to illustrate.

a = 1:100
b = 401:500
plot(b,a)
plot(b,a)


Image of result of code on the left and my goal on the right. How can I produce a 10° slope with 4 value 1.0?

@kjetil b halvorsen When you say "you must use a plot with equal scales on x and y-axes!"

Both variables a,b contain exactly 100 components, wouldn't that create equal axes?

@whuber Doing what you advised produces a slope with a 45° angle, see below

slope = .82
a = 1:100
b = slope * a
plot(a,b) ## closed as off-topic by Nick Cox, jbowman, mdewey, S. Kolassa - Reinstate Monica, AdamODec 13 '17 at 17:14

This question appears to be off-topic. The users who voted to close gave this specific reason:

• "This question appears to be off-topic because EITHER it is not about statistics, machine learning, data analysis, data mining, or data visualization, OR it focuses on programming, debugging, or performing routine operations within a statistical computing platform. If the latter, you could try the support links we maintain." – Nick Cox, jbowman, mdewey, S. Kolassa - Reinstate Monica, AdamO
If this question can be reworded to fit the rules in the help center, please edit the question.

• To get the correct angle, you must use a plot with equal scales on x and y-axes! In R, use library(MASS) and the eqscplot(). – kjetil b halvorsen Dec 11 '17 at 15:18
• Pick a number not equal to $1$ or $0$. Call it slope. Replace the second line of your code by b <- slope * a. Replace the third line by plot(a,b). – whuber Dec 11 '17 at 16:45
• @kjetilbhalvorsen you can do that with base graphics plot, just set the aspect ratio asp = 1 – Firebug Dec 11 '17 at 17:57
• Please register &/or merge your accounts (you can find information on how to do this in the My Account section of our help center), then you will be able to edit & comment on your own question. – gung - Reinstate Monica Dec 11 '17 at 18:37

slope = 3 #choose whatever you want here
#remember atan(slope) equals the degree of the slope in radians (thanks to @GermanDemidov)
a = 1:100
b = slope*a
plot(a, b, asp = 1) #asp = 1 keeps the aspect ratio between axes fixed, so the visual effect is evident


And a quick example: • worth to mention:slope = 3 should be a tan of your desired angle. in this case, slope = tan(pi / 18). – German Demidov Dec 12 '17 at 9:48
• @GermanDemidov Yeah, you're completely right, I'll mention that in the answer :) – Firebug Dec 12 '17 at 10:12