Draw different scatterplots corresponding to a sample correlation coefficient
Source:R/plot_r.R
plot_r.RdThis function illustrates the importance of looking at your data before moving to numeric methods. More specifically, it illustrates that a single correlation coefficient can correspond to wildly different patterns in the data. In all, 16 scatterplots with the same sample Pearson correlation coefficient are drawn.
Arguments
- r
The desired sample correlation coefficient. This must be a number equal to or larger than -1 and smaller than (but not equal to) 1.
- n
The number of data points per scatterplot.
- showdata
Do you want to output a dataframe containing the plotted data (TRUE) or not (FALSE, default)? You can also output the data for a specific scatterplot by setting this parameter to the corresponding number (see examples).
- plot
Do you want to draw the scatterplots (TRUE, default) or not (FALSE)?
Details
(1) The x/y data are drawn from a bivariate normal distribution. Pearson's correlation coefficient can be useful in this situation.
(2) The x data is uniformly distributed between 0 and 1; the y data are scattered normally about the regression line. This isn't too problematic either.
(3) The x data are drawn from a right-skewed distribution; the y data are scattered normally about the regression line. While all y-data follow from the same data-generating mechanism (i.e., outliers reflect the same process as ordinary data points and aren't the result of, say, transcription errors), outlying data points may exert a large effect on the correlation coefficient. (Try exporting the dataset for this plot and recomputing the correlation coefficient without the largest x-value!)
(4) Same as (3), but this time the x data are drawn from a left-skewed distribution.
(5) The x data are drawn from a normal distribution but the y values are right-skewed about the regression line. Every now and again one or a couple of datapoints will exert a large pull on the correlation coefficient.
(6) Same as (5), except the y values are left-skewed about the regression line.
(7) For increasing x values, the y values are ever more scattered about the regression line. Conceptually, Pearson's correlation coefficients underestimates how well you can anticipate a y-value for small x-values an overestimates how well you can do so for large x-values.
(8) Same as (7), except the scatter about the regression line becomes smaller for larger x-values.
(9) Pearson's correlation coefficient summarises the linear trend in the data; the trend in this panel, however, is quadratic. As a result, Pearson's correlation coefficient will underestimate the strength of the relationship between the two variables.
(10) Similar to (9) but the trend is sinusoid.
(11) There is a single positive outlier that exerts a pull on the correlation coefficient. In contrast to (3) through (6), this outlier is not caused by the same data-generating mechanism as the rest of the data, so it contaminates the estimated correlation coefficient. The regression line for the data without this outlier is plotted as a dashed red line; you'll often find that the true trend in the data go counter to the trend when the outlier isn't excluded.
(12) Similar to (11), except the outlier is negative (i.e., it pulls the correlation coefficient down).
(13) The y data are distributed bimodally about the regression line. This suggests that an important categorical predictor wasn't taken into account in the analysis.
(14) A more worrisome version of (13). There are actually two groups in the data, and this wasn't taken into account. But within each of these groups, the trend may often (not always) run counter to the overall trend. So, for instance, Pearson's correlation may suggest the presence of a positive correlation, but the true trend may actually be negative – provided the group factor is taken into account. This is known as Simpson's paradox.
(15) The data in this panel were sampled from a bivariate normal distribution but the middle part of the distribution was removed. This may be a sensible sampling strategy when you want to investigate the relationship between two variables, one of which is expensive to measure and the other cheap: Screen a large number of observations on the cheap variable, and only collect the expensive variable for the extreme observations. In a regression analysis, this sampling strategy can be highly effective in terms of power and precision. However, it artificially inflates correlation coefficients.
(16) This is what I suspect lots of datasets actually look like. The x and y data are both categorical. This needn't be too problematic; it's just that when someone mentions "r = 0.4", you think of panel (1) rather than panel (16).
Examples
plot_r(r = -0.30, n = 25)
plot_r(r = -0.30, n = 25, showdata = TRUE)
#> x y type
#> 1 0.55069173 0.69593252 1
#> 2 0.31317160 0.91988072 1
#> 3 0.52799364 0.64604891 1
#> 4 0.34325214 0.29206720 1
#> 5 0.30052646 0.88290401 1
#> 6 0.89396745 0.53941801 1
#> 7 0.87591281 0.11142679 1
#> 8 0.23789745 0.76587840 1
#> 9 0.29302238 0.37858265 1
#> 10 0.31474269 0.91196566 1
#> 11 0.55632121 0.25496889 1
#> 12 0.45510967 1.00000000 1
#> 13 0.53093804 0.36539466 1
#> 14 0.63003779 0.75883177 1
#> 15 0.79406261 0.39810872 1
#> 16 0.12079765 0.36992734 1
#> 17 1.00000000 0.52959981 1
#> 18 0.55706541 0.34668314 1
#> 19 0.24953229 0.36337311 1
#> 20 0.87614466 0.27836586 1
#> 21 0.00000000 0.41911549 1
#> 22 0.75414883 0.00000000 1
#> 23 0.03045903 0.75831029 1
#> 24 0.49481447 0.63126419 1
#> 25 0.62491273 0.89903812 1
#> 26 0.84642955 0.89620818 2
#> 27 0.72448886 0.26245426 2
#> 28 0.59095720 0.77639551 2
#> 29 0.02270330 0.55909017 2
#> 30 0.07298686 0.58301782 2
#> 31 0.00000000 0.59604394 2
#> 32 0.85344602 0.53563815 2
#> 33 0.31851114 0.15479881 2
#> 34 0.65601883 0.45159489 2
#> 35 0.48414754 0.73631188 2
#> 36 0.34361359 0.58867227 2
#> 37 0.45038026 0.76559466 2
#> 38 1.00000000 0.83792079 2
#> 39 0.65634951 0.39175383 2
#> 40 0.98527698 0.08184689 2
#> 41 0.48794739 0.10745355 2
#> 42 0.87597233 0.63004900 2
#> 43 0.95327868 0.04770456 2
#> 44 0.39214907 0.89549336 2
#> 45 0.07462513 1.00000000 2
#> 46 0.25703403 0.57846129 2
#> 47 0.16923348 0.68181448 2
#> 48 0.82896779 0.00000000 2
#> 49 0.82054465 0.36928206 2
#> 50 0.67924600 0.88580460 2
#> 51 0.43446325 0.69116973 3
#> 52 0.46907942 0.17698302 3
#> 53 0.16049577 0.03924406 3
#> 54 0.51917882 0.07341540 3
#> 55 0.26250043 0.74897688 3
#> 56 1.00000000 0.03103428 3
#> 57 0.25981759 0.35808104 3
#> 58 0.03478572 0.35246582 3
#> 59 0.06610710 0.39972606 3
#> 60 0.15458150 0.31981495 3
#> 61 0.35412629 0.33522406 3
#> 62 0.92141111 0.33424305 3
#> 63 0.19326143 0.36779923 3
#> 64 0.33904789 0.00000000 3
#> 65 0.15578619 1.00000000 3
#> 66 0.10423552 0.04535479 3
#> 67 0.00000000 0.54689976 3
#> 68 0.38165269 0.36874420 3
#> 69 0.34071883 0.53182249 3
#> 70 0.07956757 0.50897662 3
#> 71 0.12207056 0.61928663 3
#> 72 0.03553295 0.30223228 3
#> 73 0.19760632 0.23878842 3
#> 74 0.13654291 0.50620809 3
#> 75 0.08563085 0.42584137 3
#> 76 0.95197739 0.43451734 4
#> 77 0.91906208 0.46798198 4
#> 78 0.88283466 0.44223822 4
#> 79 0.81538170 0.77980484 4
#> 80 0.00000000 1.00000000 4
#> 81 1.00000000 0.33700224 4
#> 82 0.97235224 0.99615928 4
#> 83 0.94359970 0.81352516 4
#> 84 0.85665960 0.46985582 4
#> 85 0.79232829 0.60231884 4
#> 86 0.98013331 0.50551459 4
#> 87 0.90853475 0.62227761 4
#> 88 0.75406494 0.85914736 4
#> 89 0.87026829 0.29091456 4
#> 90 0.96538799 0.52232950 4
#> 91 0.80282820 0.00000000 4
#> 92 0.98019278 0.54150401 4
#> 93 0.85864382 0.34606400 4
#> 94 0.94433199 0.65031879 4
#> 95 0.98062637 0.62935025 4
#> 96 0.98639415 0.29752404 4
#> 97 0.96815257 0.90200317 4
#> 98 0.95318491 0.57513985 4
#> 99 0.93539866 0.91042844 4
#> 100 0.95703376 0.58732918 4
#> 101 0.67795431 0.35328631 5
#> 102 1.00000000 0.34727057 5
#> 103 0.22470109 0.79623167 5
#> 104 0.06424261 0.58811920 5
#> 105 0.34888571 0.11724153 5
#> 106 0.54138476 0.05326686 5
#> 107 0.21738202 0.33530626 5
#> 108 0.43276262 0.00000000 5
#> 109 0.39663844 0.44010026 5
#> 110 0.14623801 0.56854426 5
#> 111 0.08642342 0.15755425 5
#> 112 0.51737559 0.03845563 5
#> 113 0.06701969 0.86228616 5
#> 114 0.42272181 0.81553997 5
#> 115 0.58947233 0.50442389 5
#> 116 0.74325870 0.02961013 5
#> 117 0.32660904 0.11805190 5
#> 118 0.31724450 1.00000000 5
#> 119 0.11968832 0.61095933 5
#> 120 0.36464411 0.42467729 5
#> 121 0.07285682 0.13674330 5
#> 122 0.48739363 0.58188644 5
#> 123 0.33767126 0.22750895 5
#> 124 0.00000000 0.52482458 5
#> 125 0.37216313 0.14647098 5
#> 126 0.66273355 0.86158364 6
#> 127 0.24230642 0.84784809 6
#> 128 0.47179451 0.79220859 6
#> 129 0.22929341 0.94135374 6
#> 130 0.36134980 0.67906446 6
#> 131 0.47257337 0.47422938 6
#> 132 0.34375036 0.82274498 6
#> 133 0.75250058 1.00000000 6
#> 134 0.07876132 0.82529465 6
#> 135 0.06825957 0.91906593 6
#> 136 0.00000000 0.54214948 6
#> 137 0.66896949 0.78480615 6
#> 138 0.87591440 0.74151933 6
#> 139 0.20201031 0.80865991 6
#> 140 0.68958905 0.90614427 6
#> 141 0.55697321 0.86960146 6
#> 142 0.57863852 0.75354698 6
#> 143 0.48214147 0.80100064 6
#> 144 1.00000000 0.00000000 6
#> 145 0.29357383 0.83189229 6
#> 146 0.16695978 0.87983326 6
#> 147 0.29288512 0.90892985 6
#> 148 0.53104737 0.98064162 6
#> 149 0.63262512 0.86401780 6
#> 150 0.37870546 0.89861881 6
#> 151 0.00000000 0.69934467 7
#> 152 0.10939840 0.65803169 7
#> 153 0.13077026 0.78970628 7
#> 154 0.25142802 0.41625027 7
#> 155 0.26008786 0.54063116 7
#> 156 0.36426068 0.59877021 7
#> 157 0.36582652 0.51921695 7
#> 158 0.37031410 0.40571665 7
#> 159 0.51736325 0.82070971 7
#> 160 0.54468547 0.68982195 7
#> 161 0.56782103 0.69289899 7
#> 162 0.59811313 0.37056402 7
#> 163 0.62273523 1.00000000 7
#> 164 0.64099425 0.44472864 7
#> 165 0.68018989 0.36698487 7
#> 166 0.70352782 0.11440964 7
#> 167 0.70530818 0.09650375 7
#> 168 0.70662418 0.23346149 7
#> 169 0.71237528 0.32726605 7
#> 170 0.87784116 0.58939445 7
#> 171 0.92390607 0.00000000 7
#> 172 0.92791340 0.52649138 7
#> 173 0.93038104 0.56254992 7
#> 174 0.95557271 0.61493578 7
#> 175 1.00000000 0.67696359 7
#> 176 0.42849844 0.48248416 8
#> 177 0.48808275 0.59311134 8
#> 178 0.58597190 0.38031105 8
#> 179 0.27460946 0.59069796 8
#> 180 0.58067112 0.87233583 8
#> 181 0.37354058 0.16166867 8
#> 182 0.00000000 0.00000000 8
#> 183 0.35966402 1.00000000 8
#> 184 0.97858350 0.43409898 8
#> 185 0.26821849 0.87735007 8
#> 186 0.03610683 0.75284396 8
#> 187 0.52751256 0.70727799 8
#> 188 0.39592895 0.24080412 8
#> 189 0.88098139 0.19409075 8
#> 190 0.48513671 0.53164903 8
#> 191 0.50306648 0.80740168 8
#> 192 0.40917932 0.23732411 8
#> 193 1.00000000 0.31913002 8
#> 194 0.14619570 0.77678737 8
#> 195 0.81860634 0.40333419 8
#> 196 0.49199015 0.90602041 8
#> 197 0.25661292 0.94690040 8
#> 198 0.64583796 0.37466037 8
#> 199 0.87937859 0.39350425 8
#> 200 0.79449236 0.16136928 8
#> 201 0.31392586 0.21421782 9
#> 202 0.35610739 0.16621780 9
#> 203 0.51659849 0.09199075 9
#> 204 0.48103239 0.14183809 9
#> 205 0.80797185 0.37463670 9
#> 206 0.11249540 0.67485855 9
#> 207 0.31501822 0.21043712 9
#> 208 0.00000000 1.00000000 9
#> 209 0.54535097 0.03934722 9
#> 210 1.00000000 0.94542241 9
#> 211 0.14343128 0.60843894 9
#> 212 0.86683148 0.48382430 9
#> 213 0.01148432 0.91415634 9
#> 214 0.42349271 0.15585364 9
#> 215 0.16367035 0.33732415 9
#> 216 0.29033865 0.26027363 9
#> 217 0.21215474 0.36389653 9
#> 218 0.48707510 0.00000000 9
#> 219 0.55168800 0.01411590 9
#> 220 0.61437823 0.10888788 9
#> 221 0.63421280 0.11641374 9
#> 222 0.62939074 0.09166526 9
#> 223 0.17677464 0.42343281 9
#> 224 0.73381692 0.30045629 9
#> 225 0.56736070 0.06640768 9
#> 226 0.51032257 0.66560660 10
#> 227 0.32782930 0.38398791 10
#> 228 0.39727928 0.16458135 10
#> 229 0.31101273 0.34279982 10
#> 230 0.53916983 0.83710293 10
#> 231 0.87475747 0.00000000 10
#> 232 0.82981174 0.32882863 10
#> 233 0.00000000 0.46958149 10
#> 234 0.25655763 0.53515651 10
#> 235 0.59212806 0.89546864 10
#> 236 0.73560205 0.67257961 10
#> 237 0.86875839 0.05640951 10
#> 238 0.29578094 0.41715535 10
#> 239 0.32979094 0.24110175 10
#> 240 0.16542127 0.85866623 10
#> 241 0.01275703 0.59060813 10
#> 242 0.50529940 0.55023955 10
#> 243 0.88164234 0.17658860 10
#> 244 0.53148727 0.53016714 10
#> 245 1.00000000 0.49001166 10
#> 246 0.16130639 0.98607411 10
#> 247 0.99775798 0.48624676 10
#> 248 0.01111013 0.65565864 10
#> 249 0.64668274 1.00000000 10
#> 250 0.74868747 0.56877697 10
#> 251 0.00000000 0.87728166 11
#> 252 0.04285034 1.00000000 11
#> 253 0.10249010 0.63866607 11
#> 254 0.10283039 0.73374127 11
#> 255 0.12573355 0.23232480 11
#> 256 0.12954196 0.78133552 11
#> 257 0.14493576 0.81074296 11
#> 258 0.14544823 0.70588325 11
#> 259 0.16200730 0.58613060 11
#> 260 0.16224270 0.45323127 11
#> 261 0.17493687 0.43722087 11
#> 262 0.17536348 0.54440215 11
#> 263 0.18117664 0.51082593 11
#> 264 0.18674623 0.76811927 11
#> 265 0.20379441 0.26165657 11
#> 266 0.21076911 0.42708597 11
#> 267 0.21479574 0.30510135 11
#> 268 0.23632933 0.62870250 11
#> 269 0.24202363 0.48022303 11
#> 270 0.24491754 0.40640930 11
#> 271 0.24898454 0.40100403 11
#> 272 0.25619089 0.12412468 11
#> 273 0.29091506 0.00000000 11
#> 274 0.36652063 0.01726730 11
#> 275 1.00000000 0.55696644 11
#> 276 0.00000000 0.75828844 12
#> 277 0.00135348 0.30935672 12
#> 278 0.02276647 0.40804512 12
#> 279 0.02880796 0.41480293 12
#> 280 0.05103349 0.59158925 12
#> 281 0.06267192 0.68401385 12
#> 282 0.08220900 0.49437414 12
#> 283 0.08784787 0.57946958 12
#> 284 0.09520330 0.52407386 12
#> 285 0.09547819 0.46238110 12
#> 286 0.11058956 0.72017155 12
#> 287 0.11092284 0.55980523 12
#> 288 0.15632060 0.64773301 12
#> 289 0.16116661 0.59912437 12
#> 290 0.16722162 0.69503273 12
#> 291 0.16753086 0.67349302 12
#> 292 0.16828640 0.55833396 12
#> 293 0.17938547 0.74879340 12
#> 294 0.21322016 0.58289441 12
#> 295 0.22460771 0.70734541 12
#> 296 0.22910005 0.80306802 12
#> 297 0.24564546 0.76644464 12
#> 298 0.28994402 0.87819276 12
#> 299 0.33340218 1.00000000 12
#> 300 1.00000000 0.00000000 12
#> 301 0.53906646 0.34419439 13
#> 302 0.79782043 0.00000000 13
#> 303 0.57270094 0.42401346 13
#> 304 1.00000000 0.03936713 13
#> 305 0.90423564 0.21901614 13
#> 306 0.53694291 0.17088698 13
#> 307 0.00000000 0.49739430 13
#> 308 0.92934018 0.09720275 13
#> 309 0.45719013 0.13623041 13
#> 310 0.95736746 0.11066248 13
#> 311 0.44979833 0.38719136 13
#> 312 0.34805433 0.45530950 13
#> 313 0.54578789 0.85274206 13
#> 314 0.40265774 0.97035151 13
#> 315 0.34649699 0.96650593 13
#> 316 0.73168787 0.77942558 13
#> 317 0.49663460 1.00000000 13
#> 318 0.81493382 0.71876915 13
#> 319 0.80230167 0.82411293 13
#> 320 0.42686719 0.92076148 13
#> 321 0.73002476 0.85676509 13
#> 322 0.82949325 0.62771978 13
#> 323 0.84165685 0.80436279 13
#> 324 0.60310247 0.90690847 13
#> 325 0.74894542 0.77539681 13
#> 326 0.01741634 0.92224785 14
#> 327 0.18039613 1.00000000 14
#> 328 0.15991643 0.90384834 14
#> 329 0.03997451 0.71978055 14
#> 330 0.02732335 0.48236314 14
#> 331 0.00000000 0.82430487 14
#> 332 0.04378117 0.51115401 14
#> 333 0.01229308 0.49767397 14
#> 334 0.10645537 0.60071269 14
#> 335 0.06317679 0.90967212 14
#> 336 0.07397504 0.91323552 14
#> 337 0.14282084 0.94693512 14
#> 338 0.81086996 0.63478871 14
#> 339 0.76668729 0.47583770 14
#> 340 0.71978323 0.00000000 14
#> 341 0.82154080 0.85356424 14
#> 342 0.65569855 0.51682901 14
#> 343 0.77602001 0.76786194 14
#> 344 0.68355495 0.72643586 14
#> 345 0.88498310 0.81130406 14
#> 346 0.67246400 0.64277717 14
#> 347 0.71447285 0.39603507 14
#> 348 0.73592622 0.43613829 14
#> 349 0.78086823 0.55149470 14
#> 350 1.00000000 0.79770678 14
#> 351 0.00000000 0.85394022 15
#> 352 0.15222447 0.41289823 15
#> 353 0.25824915 0.74951340 15
#> 354 0.26004691 0.55209971 15
#> 355 0.34618507 0.52193343 15
#> 356 0.35178674 0.75317626 15
#> 357 0.35906881 0.49765893 15
#> 358 0.37079137 0.74779312 15
#> 359 0.37211062 0.89415606 15
#> 360 0.37573230 0.74108290 15
#> 361 0.38146850 0.54225749 15
#> 362 0.38511994 0.38065494 15
#> 363 0.83291001 1.00000000 15
#> 364 0.83524881 0.30566060 15
#> 365 0.85012777 0.70721414 15
#> 366 0.85103050 0.09031445 15
#> 367 0.86651996 0.59813036 15
#> 368 0.87285890 0.52117392 15
#> 369 0.87432130 0.79265287 15
#> 370 0.88895694 0.00000000 15
#> 371 0.89223617 0.57869209 15
#> 372 0.93830012 0.52501644 15
#> 373 0.95191148 0.61038653 15
#> 374 0.98511546 0.41246290 15
#> 375 1.00000000 0.48302804 15
#> 376 1.00000000 0.00000000 16
#> 377 0.00000000 0.32040373 16
#> 378 1.00000000 0.00000000 16
#> 379 0.50000000 0.50000000 16
#> 380 1.00000000 0.67959627 16
#> 381 0.75000000 0.30663302 16
#> 382 1.00000000 0.33979814 16
#> 383 0.50000000 0.16020186 16
#> 384 1.00000000 0.67959627 16
#> 385 1.00000000 0.56633023 16
#> 386 0.75000000 0.08010093 16
#> 387 1.00000000 0.33979814 16
#> 388 1.00000000 0.56633023 16
#> 389 0.00000000 0.32040373 16
#> 390 1.00000000 0.22653209 16
#> 391 0.00000000 1.00000000 16
#> 392 0.75000000 0.75969721 16
#> 393 0.75000000 0.64643116 16
#> 394 0.00000000 0.43366977 16
#> 395 1.00000000 0.22653209 16
#> 396 1.00000000 0.45306418 16
#> 397 1.00000000 0.33979814 16
#> 398 0.50000000 0.27346791 16
#> 399 1.00000000 0.11326605 16
#> 400 0.00000000 0.77346791 16
# Only show the data for the 12th plot
plot_r(r = 0.5, n = 250, showdata = 12)
#> x y type
#> 2751 0.00000000 0.12578813 12
#> 2752 0.02321810 0.11336735 12
#> 2753 0.04794741 0.26293836 12
#> 2754 0.04808023 0.09142868 12
#> 2755 0.06500494 0.32807736 12
#> 2756 0.07343239 0.34136633 12
#> 2757 0.07721905 0.13691673 12
#> 2758 0.07967425 0.31766535 12
#> 2759 0.08772667 0.28960614 12
#> 2760 0.08782430 0.24330632 12
#> 2761 0.08940175 0.32560718 12
#> 2762 0.08942652 0.25921468 12
#> 2763 0.09215412 0.58428026 12
#> 2764 0.09275832 0.34869128 12
#> 2765 0.09513558 0.26999241 12
#> 2766 0.09513844 0.26579112 12
#> 2767 0.09722884 0.28813326 12
#> 2768 0.09756324 0.32064898 12
#> 2769 0.09775510 0.43857448 12
#> 2770 0.09887393 0.34326009 12
#> 2771 0.10070441 0.22446434 12
#> 2772 0.10407430 0.26516263 12
#> 2773 0.10490700 0.12250282 12
#> 2774 0.10635207 0.31002063 12
#> 2775 0.10725144 0.46007122 12
#> 2776 0.11011460 0.40575791 12
#> 2777 0.11515347 0.18981708 12
#> 2778 0.11542626 0.53521294 12
#> 2779 0.11833305 0.34958766 12
#> 2780 0.11855837 0.33452879 12
#> 2781 0.11880135 0.20616595 12
#> 2782 0.12162925 0.43257352 12
#> 2783 0.12441344 0.38451292 12
#> 2784 0.12479276 0.39128454 12
#> 2785 0.12653889 0.36801933 12
#> 2786 0.12754604 0.30728226 12
#> 2787 0.12946757 0.28816196 12
#> 2788 0.13091541 0.48585836 12
#> 2789 0.13111181 0.26938489 12
#> 2790 0.13111486 0.06745074 12
#> 2791 0.13132162 0.32421400 12
#> 2792 0.13241776 0.14021653 12
#> 2793 0.13244431 0.40387391 12
#> 2794 0.13382909 0.44859031 12
#> 2795 0.13470202 0.46766075 12
#> 2796 0.13550641 0.35410970 12
#> 2797 0.13607866 0.67466783 12
#> 2798 0.13713563 0.51274615 12
#> 2799 0.13881496 0.28955419 12
#> 2800 0.13965897 0.32601221 12
#> 2801 0.14042689 0.40007616 12
#> 2802 0.14146685 0.16578326 12
#> 2803 0.14442859 0.40031277 12
#> 2804 0.14463928 0.55955175 12
#> 2805 0.14746011 0.45910824 12
#> 2806 0.14768948 0.39758686 12
#> 2807 0.14804427 0.32190491 12
#> 2808 0.14807956 0.36844116 12
#> 2809 0.14828055 0.49128674 12
#> 2810 0.14874357 0.25743717 12
#> 2811 0.14924626 0.26500510 12
#> 2812 0.15006119 0.56342672 12
#> 2813 0.15039589 0.35502557 12
#> 2814 0.15230226 0.43226536 12
#> 2815 0.15361746 0.39612547 12
#> 2816 0.15369158 0.25870489 12
#> 2817 0.15477309 0.44032384 12
#> 2818 0.15488935 0.20708410 12
#> 2819 0.15527569 0.39008787 12
#> 2820 0.15529916 0.36926673 12
#> 2821 0.15555460 0.29359137 12
#> 2822 0.15636394 0.40046021 12
#> 2823 0.15712884 0.31351303 12
#> 2824 0.15933773 0.23516453 12
#> 2825 0.15940436 0.35131329 12
#> 2826 0.16009053 0.44030393 12
#> 2827 0.16017809 0.22071649 12
#> 2828 0.16177331 0.62554232 12
#> 2829 0.16249961 0.49183084 12
#> 2830 0.16309306 0.71534459 12
#> 2831 0.16373144 0.35368335 12
#> 2832 0.16524201 0.45902912 12
#> 2833 0.16632484 0.47421242 12
#> 2834 0.16800421 0.43827025 12
#> 2835 0.16855110 0.51212986 12
#> 2836 0.16927724 0.45274017 12
#> 2837 0.16943440 0.50711454 12
#> 2838 0.17035428 0.39085263 12
#> 2839 0.17122497 0.27054581 12
#> 2840 0.17180235 0.43433023 12
#> 2841 0.17215198 0.54265658 12
#> 2842 0.17226945 0.34763721 12
#> 2843 0.17228226 0.41627408 12
#> 2844 0.17299038 0.43387547 12
#> 2845 0.17710367 0.45199515 12
#> 2846 0.17738705 0.59680034 12
#> 2847 0.17747959 0.47354221 12
#> 2848 0.17749925 0.41581110 12
#> 2849 0.18126012 0.40200497 12
#> 2850 0.18177660 0.69873942 12
#> 2851 0.18354720 0.47733136 12
#> 2852 0.18451849 0.61581039 12
#> 2853 0.18536197 0.40509665 12
#> 2854 0.18544561 0.44536636 12
#> 2855 0.18818612 0.41162580 12
#> 2856 0.18882275 0.33002469 12
#> 2857 0.18989445 0.53125101 12
#> 2858 0.19141582 0.47976403 12
#> 2859 0.19160829 0.39596121 12
#> 2860 0.19194105 0.37770627 12
#> 2861 0.19299137 0.35562379 12
#> 2862 0.19366115 0.50871232 12
#> 2863 0.19406759 0.64408310 12
#> 2864 0.19425591 0.50474448 12
#> 2865 0.19482716 0.42856672 12
#> 2866 0.19510116 0.32229467 12
#> 2867 0.19532984 0.32815320 12
#> 2868 0.19611716 0.42509502 12
#> 2869 0.19736426 0.40795232 12
#> 2870 0.19808428 0.41389405 12
#> 2871 0.19880381 0.64588184 12
#> 2872 0.19926168 0.54417736 12
#> 2873 0.20083958 0.34187622 12
#> 2874 0.20113700 0.41192239 12
#> 2875 0.20278190 0.50129591 12
#> 2876 0.20388999 0.46262054 12
#> 2877 0.20499824 0.46411796 12
#> 2878 0.20586012 0.57281619 12
#> 2879 0.20593056 0.33170365 12
#> 2880 0.20733032 0.59863294 12
#> 2881 0.20960717 0.50102886 12
#> 2882 0.21195305 0.48769588 12
#> 2883 0.21204258 0.60231513 12
#> 2884 0.21225399 0.50518604 12
#> 2885 0.21294990 0.43312088 12
#> 2886 0.21340824 0.48695794 12
#> 2887 0.21842746 0.39826414 12
#> 2888 0.21856996 0.27792849 12
#> 2889 0.21928702 0.42545980 12
#> 2890 0.22040820 0.47337622 12
#> 2891 0.22115864 0.60210192 12
#> 2892 0.22211333 0.50518598 12
#> 2893 0.22215479 0.56089313 12
#> 2894 0.22252137 0.53061135 12
#> 2895 0.22277975 0.64695391 12
#> 2896 0.22427251 0.46761489 12
#> 2897 0.22522210 0.27119170 12
#> 2898 0.22604917 0.48277400 12
#> 2899 0.22608171 0.35651427 12
#> 2900 0.22664272 0.37662112 12
#> 2901 0.22699493 0.45537074 12
#> 2902 0.22759885 0.53010644 12
#> 2903 0.22778859 0.49010772 12
#> 2904 0.23048367 0.49644108 12
#> 2905 0.23084367 0.52533518 12
#> 2906 0.23147700 0.44821495 12
#> 2907 0.23148350 0.60633144 12
#> 2908 0.23485353 0.45099954 12
#> 2909 0.23559767 0.60921540 12
#> 2910 0.23587979 0.58787399 12
#> 2911 0.23593102 0.52819273 12
#> 2912 0.23660617 0.73614952 12
#> 2913 0.23772553 0.68245529 12
#> 2914 0.24092608 0.62131858 12
#> 2915 0.24259181 0.39264304 12
#> 2916 0.24261259 0.53053842 12
#> 2917 0.24441603 0.52513107 12
#> 2918 0.24503150 0.39352645 12
#> 2919 0.24512293 0.45856169 12
#> 2920 0.24562453 0.63019249 12
#> 2921 0.24623397 0.64240581 12
#> 2922 0.24696812 0.55216835 12
#> 2923 0.24886046 0.30875861 12
#> 2924 0.25029068 0.49417197 12
#> 2925 0.25168539 0.41957333 12
#> 2926 0.25176294 0.38964987 12
#> 2927 0.25287358 0.60756821 12
#> 2928 0.25398282 0.54983697 12
#> 2929 0.25398516 0.58976290 12
#> 2930 0.25473445 0.58886755 12
#> 2931 0.25488214 0.52223099 12
#> 2932 0.25652575 0.60608917 12
#> 2933 0.25706295 0.54997426 12
#> 2934 0.25745948 0.54049117 12
#> 2935 0.25832910 0.69456672 12
#> 2936 0.25856740 0.64073087 12
#> 2937 0.25998116 0.47163289 12
#> 2938 0.26181100 0.63032427 12
#> 2939 0.26359606 0.57746361 12
#> 2940 0.26371983 0.41723289 12
#> 2941 0.26429885 0.65296711 12
#> 2942 0.26487316 0.51731529 12
#> 2943 0.26509342 0.49645995 12
#> 2944 0.26626817 0.61251218 12
#> 2945 0.26887639 0.80315092 12
#> 2946 0.26995844 0.55103228 12
#> 2947 0.27021376 0.58878620 12
#> 2948 0.27044647 0.63908958 12
#> 2949 0.27107546 0.43267620 12
#> 2950 0.27229211 0.57945198 12
#> 2951 0.27458541 0.53442969 12
#> 2952 0.27613858 0.62513557 12
#> 2953 0.27639493 0.65321237 12
#> 2954 0.27792600 0.42400084 12
#> 2955 0.28074707 0.69293865 12
#> 2956 0.28141655 0.59733444 12
#> 2957 0.28362624 0.54464926 12
#> 2958 0.28515851 0.57889730 12
#> 2959 0.29252906 0.68113502 12
#> 2960 0.29291117 0.73115013 12
#> 2961 0.29402124 0.51515547 12
#> 2962 0.29514723 0.46007166 12
#> 2963 0.29590965 0.82366915 12
#> 2964 0.29615483 0.76433354 12
#> 2965 0.29895918 0.50411299 12
#> 2966 0.30248629 0.59507010 12
#> 2967 0.30322599 0.56600454 12
#> 2968 0.30369084 0.49888445 12
#> 2969 0.31127033 0.73947585 12
#> 2970 0.31280683 0.79706190 12
#> 2971 0.31546842 0.70034489 12
#> 2972 0.31564614 0.53486321 12
#> 2973 0.31667334 0.61446030 12
#> 2974 0.31898568 0.59995663 12
#> 2975 0.31932730 0.40060197 12
#> 2976 0.32008182 0.55608287 12
#> 2977 0.32070162 0.62955765 12
#> 2978 0.32094105 0.56911845 12
#> 2979 0.32139479 0.53439725 12
#> 2980 0.32424810 0.76752354 12
#> 2981 0.32581441 0.72698408 12
#> 2982 0.32659125 0.65769842 12
#> 2983 0.32669650 0.64925164 12
#> 2984 0.33527979 0.47988827 12
#> 2985 0.33733542 0.70339623 12
#> 2986 0.33898547 0.63374330 12
#> 2987 0.34355923 0.93593251 12
#> 2988 0.34454096 0.74077500 12
#> 2989 0.34618638 1.00000000 12
#> 2990 0.35066039 0.67341053 12
#> 2991 0.35116572 0.74485752 12
#> 2992 0.35149639 0.63664745 12
#> 2993 0.35182810 0.70825386 12
#> 2994 0.35289968 0.60626683 12
#> 2995 0.35634151 0.66234360 12
#> 2996 0.36084871 0.66824529 12
#> 2997 0.36695099 0.74804632 12
#> 2998 0.37279682 0.62794784 12
#> 2999 0.38331000 0.65210510 12
#> 3000 1.00000000 0.00000000 12
# Generate data for the 14th plot, don't draw scatterplots
plot_r(r = 0.3, n = 12, showdata = 14, plot = FALSE)
#> x y type
#> 157 0.02882361 0.0000000 14
#> 158 0.10762908 0.4244915 14
#> 159 0.02463182 0.4141794 14
#> 160 0.00000000 0.8303447 14
#> 161 0.16279133 0.1924545 14
#> 162 0.12947547 0.1738569 14
#> 163 0.85511851 0.1164171 14
#> 164 0.84990137 1.0000000 14
#> 165 0.89284701 0.6045993 14
#> 166 0.75716232 0.8426503 14
#> 167 1.00000000 0.2538209 14
#> 168 0.93018381 0.6325634 14