Change

Author

Sara S

Installing packages

library(tidyverse) # Tidy data processing and plotting
── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
✔ dplyr     1.1.4     ✔ readr     2.1.5
✔ forcats   1.0.0     ✔ stringr   1.5.1
✔ ggplot2   3.5.1     ✔ tibble    3.2.1
✔ lubridate 1.9.3     ✔ tidyr     1.3.1
✔ purrr     1.0.2     
── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
✖ dplyr::filter() masks stats::filter()
✖ dplyr::lag()    masks stats::lag()
ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(ggformula) # Formula based plots
Loading required package: scales

Attaching package: 'scales'

The following object is masked from 'package:purrr':

    discard

The following object is masked from 'package:readr':

    col_factor

Loading required package: ggridges

New to ggformula?  Try the tutorials: 
    learnr::run_tutorial("introduction", package = "ggformula")
    learnr::run_tutorial("refining", package = "ggformula")
library(mosaic) # Our go-to package
Registered S3 method overwritten by 'mosaic':
  method                           from   
  fortify.SpatialPolygonsDataFrame ggplot2

The 'mosaic' package masks several functions from core packages in order to add 
additional features.  The original behavior of these functions should not be affected by this.

Attaching package: 'mosaic'

The following object is masked from 'package:Matrix':

    mean

The following object is masked from 'package:scales':

    rescale

The following objects are masked from 'package:dplyr':

    count, do, tally

The following object is masked from 'package:purrr':

    cross

The following object is masked from 'package:ggplot2':

    stat

The following objects are masked from 'package:stats':

    binom.test, cor, cor.test, cov, fivenum, IQR, median, prop.test,
    quantile, sd, t.test, var

The following objects are masked from 'package:base':

    max, mean, min, prod, range, sample, sum
library(skimr) # Another Data inspection package

Attaching package: 'skimr'

The following object is masked from 'package:mosaic':

    n_missing
library(kableExtra) # Making good tables with data

Attaching package: 'kableExtra'

The following object is masked from 'package:dplyr':

    group_rows
library(GGally) # Corr plots
Registered S3 method overwritten by 'GGally':
  method from   
  +.gg   ggplot2
library(corrplot) # More corrplots
corrplot 0.94 loaded
library(ggExtra) # Making Combination Plots

# devtools::install_github("rpruim/Lock5withR")
library(Lock5withR) # Datasets
library(palmerpenguins) # A famous dataset

library(easystats) # Easy Statistical Analysis and Charts
# Attaching packages: easystats 0.7.3
✔ bayestestR  0.14.0   ✔ correlation 0.8.5 
✔ datawizard  0.13.0   ✔ effectsize  0.8.9 
✔ insight     0.20.5   ✔ modelbased  0.8.8 
✔ performance 0.12.3   ✔ parameters  0.22.2
✔ report      0.5.9    ✔ see         0.9.0 
library(correlation) # Different Types of Correlations
# From the easystats collection of packages

Dataset: HollywoodMovies2011

HollywoodMovies2011 -> movies
glimpse(movies)
Rows: 136
Columns: 14
$ Movie             <fct> "Insidious", "Paranormal Activity 3", "Bad Teacher",…
$ LeadStudio        <fct> Sony, Independent, Independent, Warner Bros, Relativ…
$ RottenTomatoes    <int> 67, 68, 44, 96, 90, 93, 75, 35, 63, 69, 69, 49, 26, …
$ AudienceScore     <int> 65, 58, 38, 92, 77, 84, 91, 58, 74, 73, 72, 57, 68, …
$ Story             <fct> Monster Force, Monster Force, Comedy, Rivalry, Rival…
$ Genre             <fct> Horror, Horror, Comedy, Fantasy, Comedy, Romance, Dr…
$ TheatersOpenWeek  <int> 2408, 3321, 3049, 4375, 2918, 944, 2534, 3615, NA, 2…
$ BOAverageOpenWeek <int> 5511, 15829, 10365, 38672, 8995, 6177, 10278, 23775,…
$ DomesticGross     <dbl> 54.01, 103.66, 100.29, 381.01, 169.11, 56.18, 169.22…
$ ForeignGross      <dbl> 43.00, 98.24, 115.90, 947.10, 119.28, 83.00, 30.10, …
$ WorldGross        <dbl> 97.009, 201.897, 216.196, 1328.111, 288.382, 139.177…
$ Budget            <dbl> 1.5, 5.0, 20.0, 125.0, 32.5, 17.0, 25.0, 80.0, 0.2, …
$ Profitability     <dbl> 64.672667, 40.379400, 10.809800, 10.624888, 8.873292…
$ OpeningWeekend    <dbl> 13.27, 52.57, 31.60, 169.19, 26.25, 5.83, 26.04, 85.…

The numeric values of movie

movies_quant <- movies %>%
  drop_na() %>%
  select(where(is.numeric))
movies_quant
    RottenTomatoes AudienceScore TheatersOpenWeek BOAverageOpenWeek
1               67            65             2408              5511
2               68            58             3321             15829
3               44            38             3049             10365
4               96            92             4375             38672
5               90            77             2918              8995
6               93            84              944              6177
7               75            91             2534             10278
8               35            58             3615             23775
9               69            73             2756              6860
10              69            72             3040              9310
11              49            57             3018              6512
12              26            68             4061             34012
13              35            67             4088             23937
14              56            52             2994              8469
15              71            73             3826             10252
16              82            78             3379             10492
17              83            87             3648             15024
18              23            31             3328              2615
19              23            50             3395             10489
20              93            93             2458              3517
21              93            79             2886              3929
22              82            80             3925             12142
23              55            57             3043              7183
24              85            76             2199              4761
25              71            68             2926              6364
26              34            61             4155             21697
27              61            56             3155              5715
28              92            81             2961              5002
29              93            86             3448              8672
30              37            54             1719              2955
31              30            39             2787              3390
32              60            79             3703             10704
33              38            55             1552              2470
34              47            63             3167              7500
35              47            54             3339              5524
36              38            55             3122              3860
37              60            72             2817              5979
38              35            50             3417             10411
39              77            80             3955             16618
40              26            50             3579             10490
41              78            81             3020              6326
42              38            56             4115             16072
43              22            40             3295              3534
44              19            63             3548              8601
45              78            75             3715             17512
46              20            43             2985              4955
47              71            71             3549              4383
48              72            67             2840              7450
49               4            29             2534              5921
50              46            79             2214              4789
51              58            81             3440              7942
52              72            70             2802              4655
53              36            59             3112             10349
54              58            57             3305              5656
55              32            57             3154              6167
56              84            81             3507              5461
57               4            46             3118              3504
58              35            44             2950              4588
59              10            32             2816              3769
60              76            70             1826              5427
61              84            63             3222              6935
62              87            88             3641             15134
63              83            76             3952              8623
64              14            42             3482              5763
65              71            67             2535              4880
66              11            41             3030              4622
67              95            89             2993              6516
68              38            50             2473              3014
69              44            47             3584              9335
70              84            82             2707              4879
71              88            69             3917              9722
72              24            48             3017              2875
73              34            46             2973              4405
74              84            61                4             93230
75              19            50             1952              5047
76              68            61             3367              7135
77              97            87             3440              8500
78              16            25             2806              2995
79              28            55             2614              3982
80              24            50             3002              1806
81              43            48             2888              4616
82              24            53             2913              4645
83              17            37             2864              5221
84              53            52             2703              4226
85              59            37             2760              3089
86              75            68             3114              2477
87              26            49             3276              3731
88              91            79             2405              3267
89              27            48             3816             13935
90              23            48             3033              6284
91              39            43             2296              3782
92              44            50             3750              9715
93               4            59             3438              7273
94              23            31             2940              6060
95              83            93             1869              2805
96              83            84              247              7174
97              41            59             3606              5889
98               7            38             2661              3055
99              25            48             2986              3132
100             36            52             2996              2835
101             45            38             2290              2265
102             92            82             3376              3537
103             56            65              707              4960
104             22            34             3015              3324
105             26            36             2769              3380
106             50            48             2273              2259
107             46            66              265              3856
108             66            55              106              6111
109             62            57               22              4890
110             36            43             3117              2218
111             38            62             2150              1513
    DomesticGross ForeignGross WorldGross Budget Profitability OpeningWeekend
1           54.01        43.00     97.009    1.5    64.6726667          13.27
2          103.66        98.24    201.897    5.0    40.3794000          52.57
3          100.29       115.90    216.196   20.0    10.8098000          31.60
4          381.01       947.10   1328.111  125.0    10.6248880         169.19
5          169.11       119.28    288.382   32.5     8.8732923          26.25
6           56.18        83.00    139.177   17.0     8.1868824           5.83
7          169.22        30.10    199.324   25.0     7.9729600          26.04
8          254.46       327.00    581.464   80.0     7.2683000          85.95
9           79.25        82.60    161.849   27.0     5.9944074          18.91
10         117.54        92.10    209.638   35.0     5.9896571          28.30
11          70.60        77.10    147.700   25.0     5.9080000          19.70
12         260.80       374.00    634.800  110.0     5.7709091         138.12
13         352.39       770.81   1123.195  195.0     5.7599744          97.85
14          99.97        94.00    193.967   36.0     5.3879722          25.36
15         143.62       341.02    484.634   90.0     5.3848222          39.23
16         127.00       132.71    259.713   50.0     5.1942600          35.45
17         176.70       304.52    481.226   93.0     5.1744731          54.81
18          17.69         7.88     25.562    5.0     5.1124000           8.70
19         142.61       419.54    562.158  110.0     5.1105273          35.61
20          34.90         1.62     36.511    8.0     4.5638750           8.64
21          34.68        32.33     67.007   15.0     4.4671333          11.34
22         165.25       497.78    663.024  150.0     4.4201600          47.66
23          63.69        67.10    130.786   30.0     4.3595333          21.86
24          40.49        13.70     54.194   12.5     4.3355200          10.47
25          55.80        93.74    149.541   35.0     4.2726000          18.62
26         241.07       802.80   1043.871  250.0     4.1754840          90.15
27          42.59       115.30    157.887   40.0     3.9471750          18.03
28          54.71        68.57    123.278   32.0     3.8524375          14.81
29         197.80       336.70    534.500  145.0     3.6862069          29.55
30          13.84        41.40     55.241   15.0     3.6827333           5.08
31          23.20        85.40    108.600   30.0     3.6200000           9.40
32         179.04       261.00    440.040  125.0     3.5203200          39.63
33           8.31       149.63    157.939   45.0     3.5097556           3.83
34          52.70        19.72     72.416   21.0     3.4483810          23.75
35          68.22       119.14    187.355   55.0     3.4064545          18.45
36          36.49        90.90    127.393   40.0     3.1848250          12.05
37          58.71        58.39    117.094   38.0     3.0814211          16.84
38          83.55       128.27    211.818   70.0     3.0259714          35.57
39         181.03       267.48    448.512  150.0     2.9900800          65.72
40         108.09        75.87    183.953   63.0     2.9198889          37.54
41          84.34        58.50    142.841   50.0     2.8568200          19.10
42         191.45       360.40    551.850  200.0     2.7592500          66.14
43          38.54        35.54     74.080   27.0     2.7437037          11.64
44         103.03       111.92    214.945   80.0     2.6868125          30.51
45         176.65       191.75    368.404  140.0     2.6314571          65.06
46          33.00        63.00     96.000   37.0     2.5945946          14.80
47          51.16        10.90     62.053   24.0     2.5855417          15.56
48          62.50        65.37    127.868   50.2     2.5471713          21.16
49          37.30         3.19     40.492   16.0     2.5307500          15.00
50          43.85         0.41     44.267   18.0     2.4592778          10.60
51          83.61       186.20    269.811  110.0     2.4528273          27.32
52          37.41        60.57     97.983   40.0     2.4495750          13.04
53          80.49       102.00    182.485   75.0     2.4331333          32.21
54          38.18        58.96     97.137   40.0     2.4284250          18.69
55          55.10        89.40    144.500   60.0     2.4083333          19.45
56          71.08        16.86     87.947   37.0     2.3769459          19.15
57          28.07        54.00     82.069   35.0     2.3448286          10.93
58          45.06        38.10     83.160   36.0     2.3100000          13.54
59          24.80        66.80     91.600   40.0     2.2900000          10.60
60          31.18        14.25     45.429   20.0     2.2714500           9.91
61          75.64        59.80    135.443   60.0     2.2573833          22.40
62         146.41       207.22    353.623  160.0     2.2101437          55.10
63         142.09       142.30    284.386  130.0     2.1875846          34.08
64          80.36        89.94    170.301   80.0     2.1287625          20.07
65          40.26        23.52     63.781   30.0     2.1260333          12.37
66          37.66        51.50     89.162   42.0     2.1229048          14.01
67          74.21        27.90    102.109   50.0     2.0421800          19.50
68          23.18        16.48     39.664   20.0     1.9832000           7.45
69          98.80       129.00    227.800  120.0     1.8983333          33.50
70          58.01        17.00     75.009   40.0     1.8752250          13.21
71         123.26       121.90    245.154  135.0     1.8159556          38.08
72          20.25       111.90    132.147   75.0     1.7619600           8.67
73          35.61        16.80     52.408   30.0     1.7469333          13.10
74          13.30        41.00     54.303   32.0     1.6969687           0.37
75          27.87         0.97     28.833   17.0     1.6960588           9.85
76          74.50        47.00    121.504   75.0     1.6200533          24.03
77          66.63         5.80     72.426   45.0     1.6094667          29.24
78          18.88        19.83     38.702   25.0     1.5480800           8.40
79          36.67        24.30     60.965   40.0     1.5241250          10.41
80          14.01        16.42     30.426   20.0     1.5213000           5.42
81          37.05         3.49     40.546   28.0     1.4480714          13.33
82          37.08        33.75     70.833   52.0     1.3621731          13.53
83          29.14        49.17     78.308   60.0     1.3051333          14.95
84          29.20        22.00     51.200   40.0     1.2800000          11.40
85          24.05         7.50     31.546   25.0     1.2618400           8.53
86          18.30        18.80     37.102   30.0     1.2367333           7.71
87          33.04        12.70     45.735   40.0     1.1433750          12.22
88          26.69         6.46     33.152   30.0     1.1050667           7.86
89         116.60       103.25    219.851  200.0     1.0992550          53.17
90          36.39        53.40     89.792   82.0     1.0950244          19.06
91          19.49         7.63     27.121   25.0     1.0848400           8.68
92         100.24        74.58    174.821  163.0     1.0725215          36.43
93          68.91        15.00     83.911   79.0     1.0621646          25.00
94          48.50        21.20     69.700   70.0     0.9957143          17.80
95          13.66         9.40     23.057   25.0     0.9222800           5.24
96           5.31         2.95      8.258   10.0     0.8258000           1.75
97          57.31        49.20    106.507  135.0     0.7889407          21.24
98          21.30        17.20     38.502   50.0     0.7700400           8.13
99          25.12        27.84     52.961   70.0     0.7565857           9.35
100         16.93        10.50     27.428   38.0     0.7217895           8.49
101         10.72        18.21     28.931   45.0     0.6429111           5.19
102         33.70        57.50     91.203  150.0     0.6080200          12.07
103         11.54         2.67     14.211   25.0     0.5684400           3.51
104         21.30        27.50     48.795   90.0     0.5421667          10.02
105         21.60         3.26     24.856   49.9     0.4981162           9.36
106         13.07         8.48     21.552   45.0     0.4789333           5.14
107          4.46         9.73     14.190   30.0     0.4730000           1.02
108          4.40         0.40      4.800   15.0     0.3200000           0.64
109          0.97         5.40      6.370   21.0     0.3033333           0.11
110         21.39        17.60     38.992  150.0     0.2599467           6.91
111          7.17         0.24      7.410   41.0     0.1807317           3.25

Domestic Vs World gross earnings

movies %>%
  gf_point(DomesticGross ~ WorldGross) %>%
  gf_lm() %>%
  gf_labs(
    title = "Scatter Plot",
    subtitle = "Movie Gross Earnings: Domestics vs World"
  )
Warning: Removed 2 rows containing non-finite outside the scale range
(`stat_lm()`).
Warning: Removed 2 rows containing missing values or values outside the scale range
(`geom_point()`).
Warning: Using the `size` aesthetic with geom_line was deprecated in ggplot2 3.4.0.
ℹ Please use the `linewidth` aesthetic instead.

Movies which don’t predict a profit after its first week

movies %>%
  gf_point(Profitability ~ OpeningWeekend) %>%
  gf_lm() %>%
  gf_labs(
    title = "Scatter Plot",
    subtitle = "Movies: Does Opening Week Earnings indicate Profitability?"
  )
Warning: Removed 5 rows containing non-finite outside the scale range
(`stat_lm()`).
Warning: Removed 5 rows containing missing values or values outside the scale range
(`geom_point()`).

Movie ratings by critics on rotten tomatoes vs the audience score

movies %>%
  gf_point(RottenTomatoes ~ AudienceScore) %>%
  gf_lm() %>%
  gf_labs(
    title = "Scatter Plot",
    subtitle = "Movie Ratings: Tomatoes vs Audience"
  )
Warning: Removed 2 rows containing non-finite outside the scale range
(`stat_lm()`).
Warning: Removed 2 rows containing missing values or values outside the scale range
(`geom_point()`).

Ratings by critics on rotten tomatoes vs the audience score for each movie genre

movies %>%
  drop_na() %>%
  gf_point(RottenTomatoes ~ AudienceScore,
    color = ~Genre
  ) %>%
  gf_lm() %>%
  gf_labs(
    title = "Scatter Plot",
    subtitle = "Movie Ratings: Trends by Genre"
  )

GGally::ggpairs(
  movies %>% drop_na(),
  # Select Quant variables only for now
  columns = c(
    "RottenTomatoes", "AudienceScore", "DomesticGross", "ForeignGross"
  ),
  switch = "both",
  # axis labels in more traditional locations(left and bottom)

  progress = FALSE,
  # no compute progress messages needed

  # Choose the diagonal graphs (always single variable! Think!)
  diag = list(continuous = "barDiag"),
  # choosing histogram,not density

  # Choose lower triangle graphs, two-variable graphs
  lower = list(continuous = wrap("smooth", alpha = 0.3, se = FALSE)),
  title = "Movies Data Correlations Plot #1"
)
`stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
`stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
`stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
`stat_bin()` using `bins = 30`. Pick better value with `binwidth`.

The relationship between Budget and Profitability and even either of the gross earnings and Profitability

GGally::ggpairs(
  movies %>% drop_na(),
  # Select Quant variables only for now
  columns = c(
    "Budget", "Profitability", "DomesticGross", "ForeignGross"
  ),
  switch = "both",
  # axis labels in more traditional locations(left and bottom)

  progress = FALSE,
  # no compute progress messages needed

  # Choose the diagonal graphs (always single variable! Think!)
  diag = list(continuous = "barDiag"),
  # choosing histogram,not density

  # Choose lower triangle graphs, two-variable graphs
  lower = list(continuous = wrap("smooth", alpha = 0.3, se = FALSE)),
  title = "Movies Data Correlations Plot #2"
)
`stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
`stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
`stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
`stat_bin()` using `bins = 30`. Pick better value with `binwidth`.

Correlation test: Profitability vs Budget

mosaic::cor_test(Profitability ~ Budget, data = movies) %>%
  broom::tidy() %>%
  knitr::kable(
    digits = 2,
    caption = "Movie Profitability vs Budget"
  )
Movie Profitability vs Budget
estimate statistic p.value parameter conf.low conf.high method alternative
-0.08 -0.96 0.34 132 -0.25 0.09 Pearson’s product-moment correlation two.sided

Correlation test: Domestic Gross vs Budget

mosaic::cor_test(DomesticGross ~ Budget, data = movies) %>%
  broom::tidy() %>%
  knitr::kable(
    digits = 2,
    caption = "Movie Domestic Gross vs Budget"
  )
Movie Domestic Gross vs Budget
estimate statistic p.value parameter conf.low conf.high method alternative
0.7 11.06 0 131 0.6 0.77 Pearson’s product-moment correlation two.sided

Correlation test: Foreign Gross vs Budget

mosaic::cor_test(ForeignGross ~ Budget, data = movies) %>%
  broom::tidy() %>%
  knitr::kable(
    digits = 2,
    caption = "Movie Foreign Gross vs Budget"
  )
Movie Foreign Gross vs Budget
estimate statistic p.value parameter conf.low conf.high method alternative
0.69 10.22 0 118 0.58 0.77 Pearson’s product-moment correlation two.sided

Dataset: mtcars

glimpse(mtcars)
Rows: 32
Columns: 11
$ mpg  <dbl> 21.0, 21.0, 22.8, 21.4, 18.7, 18.1, 14.3, 24.4, 22.8, 19.2, 17.8,…
$ cyl  <dbl> 6, 6, 4, 6, 8, 6, 8, 4, 4, 6, 6, 8, 8, 8, 8, 8, 8, 4, 4, 4, 4, 8,…
$ disp <dbl> 160.0, 160.0, 108.0, 258.0, 360.0, 225.0, 360.0, 146.7, 140.8, 16…
$ hp   <dbl> 110, 110, 93, 110, 175, 105, 245, 62, 95, 123, 123, 180, 180, 180…
$ drat <dbl> 3.90, 3.90, 3.85, 3.08, 3.15, 2.76, 3.21, 3.69, 3.92, 3.92, 3.92,…
$ wt   <dbl> 2.620, 2.875, 2.320, 3.215, 3.440, 3.460, 3.570, 3.190, 3.150, 3.…
$ qsec <dbl> 16.46, 17.02, 18.61, 19.44, 17.02, 20.22, 15.84, 20.00, 22.90, 18…
$ vs   <dbl> 0, 0, 1, 1, 0, 1, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0,…
$ am   <dbl> 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0,…
$ gear <dbl> 4, 4, 4, 3, 3, 3, 3, 4, 4, 4, 4, 3, 3, 3, 3, 3, 3, 4, 4, 4, 3, 3,…
$ carb <dbl> 4, 4, 1, 1, 2, 1, 4, 2, 2, 4, 4, 3, 3, 3, 4, 4, 4, 1, 2, 1, 1, 2,…

Coorelations

cor <- correlation::correlation(mtcars)
cor
# Correlation Matrix (pearson-method)

Parameter1 | Parameter2 |     r |         95% CI | t(30) |         p
--------------------------------------------------------------------
mpg        |        cyl | -0.85 | [-0.93, -0.72] | -8.92 | < .001***
mpg        |       disp | -0.85 | [-0.92, -0.71] | -8.75 | < .001***
mpg        |         hp | -0.78 | [-0.89, -0.59] | -6.74 | < .001***
mpg        |       drat |  0.68 | [ 0.44,  0.83] |  5.10 | < .001***
mpg        |         wt | -0.87 | [-0.93, -0.74] | -9.56 | < .001***
mpg        |       qsec |  0.42 | [ 0.08,  0.67] |  2.53 | 0.222    
mpg        |         vs |  0.66 | [ 0.41,  0.82] |  4.86 | 0.001**  
mpg        |         am |  0.60 | [ 0.32,  0.78] |  4.11 | 0.008**  
mpg        |       gear |  0.48 | [ 0.16,  0.71] |  3.00 | 0.097    
mpg        |       carb | -0.55 | [-0.75, -0.25] | -3.62 | 0.024*   
cyl        |       disp |  0.90 | [ 0.81,  0.95] | 11.45 | < .001***
cyl        |         hp |  0.83 | [ 0.68,  0.92] |  8.23 | < .001***
cyl        |       drat | -0.70 | [-0.84, -0.46] | -5.37 | < .001***
cyl        |         wt |  0.78 | [ 0.60,  0.89] |  6.88 | < .001***
cyl        |       qsec | -0.59 | [-0.78, -0.31] | -4.02 | 0.010*   
cyl        |         vs | -0.81 | [-0.90, -0.64] | -7.59 | < .001***
cyl        |         am | -0.52 | [-0.74, -0.21] | -3.36 | 0.043*   
cyl        |       gear | -0.49 | [-0.72, -0.17] | -3.10 | 0.079    
cyl        |       carb |  0.53 | [ 0.22,  0.74] |  3.40 | 0.041*   
disp       |         hp |  0.79 | [ 0.61,  0.89] |  7.08 | < .001***
disp       |       drat | -0.71 | [-0.85, -0.48] | -5.53 | < .001***
disp       |         wt |  0.89 | [ 0.78,  0.94] | 10.58 | < .001***
disp       |       qsec | -0.43 | [-0.68, -0.10] | -2.64 | 0.197    
disp       |         vs | -0.71 | [-0.85, -0.48] | -5.53 | < .001***
disp       |         am | -0.59 | [-0.78, -0.31] | -4.02 | 0.010*   
disp       |       gear | -0.56 | [-0.76, -0.26] | -3.66 | 0.023*   
disp       |       carb |  0.39 | [ 0.05,  0.65] |  2.35 | 0.303    
hp         |       drat | -0.45 | [-0.69, -0.12] | -2.75 | 0.170    
hp         |         wt |  0.66 | [ 0.40,  0.82] |  4.80 | 0.001**  
hp         |       qsec | -0.71 | [-0.85, -0.48] | -5.49 | < .001***
hp         |         vs | -0.72 | [-0.86, -0.50] | -5.73 | < .001***
hp         |         am | -0.24 | [-0.55,  0.12] | -1.37 | > .999   
hp         |       gear | -0.13 | [-0.45,  0.23] | -0.69 | > .999   
hp         |       carb |  0.75 | [ 0.54,  0.87] |  6.21 | < .001***
drat       |         wt | -0.71 | [-0.85, -0.48] | -5.56 | < .001***
drat       |       qsec |  0.09 | [-0.27,  0.43] |  0.50 | > .999   
drat       |         vs |  0.44 | [ 0.11,  0.68] |  2.69 | 0.187    
drat       |         am |  0.71 | [ 0.48,  0.85] |  5.57 | < .001***
drat       |       gear |  0.70 | [ 0.46,  0.84] |  5.36 | < .001***
drat       |       carb | -0.09 | [-0.43,  0.27] | -0.50 | > .999   
wt         |       qsec | -0.17 | [-0.49,  0.19] | -0.97 | > .999   
wt         |         vs | -0.55 | [-0.76, -0.26] | -3.65 | 0.023*   
wt         |         am | -0.69 | [-0.84, -0.45] | -5.26 | < .001***
wt         |       gear | -0.58 | [-0.77, -0.29] | -3.93 | 0.012*   
wt         |       carb |  0.43 | [ 0.09,  0.68] |  2.59 | 0.205    
qsec       |         vs |  0.74 | [ 0.53,  0.87] |  6.11 | < .001***
qsec       |         am | -0.23 | [-0.54,  0.13] | -1.29 | > .999   
qsec       |       gear | -0.21 | [-0.52,  0.15] | -1.19 | > .999   
qsec       |       carb | -0.66 | [-0.82, -0.40] | -4.76 | 0.001**  
vs         |         am |  0.17 | [-0.19,  0.49] |  0.94 | > .999   
vs         |       gear |  0.21 | [-0.15,  0.52] |  1.15 | > .999   
vs         |       carb | -0.57 | [-0.77, -0.28] | -3.80 | 0.017*   
am         |       gear |  0.79 | [ 0.62,  0.89] |  7.16 | < .001***
am         |       carb |  0.06 | [-0.30,  0.40] |  0.32 | > .999   
gear       |       carb |  0.27 | [-0.08,  0.57] |  1.56 | > .999   

p-value adjustment method: Holm (1979)
Observations: 32
cor %>%
  # Filter for target variable `mpg` and plot
  filter(Parameter1 == "mpg") %>%
  gf_point(r ~ reorder(Parameter2, r), size = 4) %>%
  gf_errorbar(CI_low + CI_high ~ reorder(Parameter2, r),
    width = 0.5
  ) %>%
  gf_hline(yintercept = 0, color = "black", linewidth = 2) %>%
  gf_labs(
    title = "Correlation Errorbar Chart",
    subtitle = "Target variable: mpg",
    x = "Predictor Variable",
    y = "Correlation Score with mpg"
  )

Dataset: Penguins

penguins %>%
  drop_na() %>%
  gf_point(body_mass_g ~ flipper_length_mm, colour = ~species) %>%
  gf_smooth(method = "lm") %>%
  gf_refine(scale_colour_brewer(palette = "Accent")) %>%
  gf_labs(title = "Scatter Plot with Marginal Densities") %>%
  ggExtra::ggMarginal(
    type = "density", groupColour = TRUE,
    groupFill = TRUE, margins = "both"
  )

lm = linear model: enhances the interpretability of scatter plots by providing a clear visual indication of the relationship between the two variables through the fitted regression line.