-1
$\begingroup$

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.

enter image description here

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.

enter image description here

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)

enter image description here

$\endgroup$

closed as off-topic by Nick Cox, jbowman, mdewey, S. Kolassa - Reinstate Monica, AdamO Dec 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.

  • 1
    $\begingroup$ 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(). $\endgroup$ – kjetil b halvorsen Dec 11 '17 at 15:18
  • 1
    $\begingroup$ 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). $\endgroup$ – whuber Dec 11 '17 at 16:45
  • 1
    $\begingroup$ @kjetilbhalvorsen you can do that with base graphics plot, just set the aspect ratio asp = 1 $\endgroup$ – Firebug Dec 11 '17 at 17:57
  • $\begingroup$ 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. $\endgroup$ – gung - Reinstate Monica Dec 11 '17 at 18:37
1
$\begingroup$

Following @whuber comments,

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:

enter image description here

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.