I think you can consider GGally
package. It draws pairwise scatter plot using ggplot2
. I guess this is what you want.
library(tidyverse)
(mu_sd <- # parameters
tribble(
~m, ~s,
#--/--/
1, 3,
2, 4,
3, 3,
4, 4,
5, 2,
3, .5
))
#> # A tibble: 6 x 2
#> m s
#> <dbl> <dbl>
#> 1 1 3
#> 2 2 4
#> 3 3 3
#> 4 4 4
#> 5 5 2
#> 6 3 0.5
Applying rnorm
to this data frame, we can get another data frame to draw a plot
set.seed(10)
(rand_norm <-
mu_sd %>%
apply(1, rnorm, n = 10) %>% # to each row
as_tibble())
#> # A tibble: 10 x 6
#> V1 V2 V3 V4 V5 V6
#> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
#> 1 1.02 3.10 2.40 2.15 6.09 2.60
#> 2 2.82 4.76 0.815 3.92 1.24 0.165
#> 3 -0.371 1.76 2.33 4.97 4.17 4.37
#> 4 2.40 4.99 0.881 4.18 2.83 2.64
#> 5 1.29 2.74 1.73 2.62 4.03 3.51
#> 6 3.39 4.09 2.63 2.56 1.97 1.29
#> 7 -0.208 1.05 2.31 4.36 5.23 2.10
#> 8 2.64 3.80 2.13 2.24 1.70 1.03
#> 9 -0.627 2.93 2.90 3.68 4.32 2.35
#> 10 2.74 4.48 2.75 3.35 2.66 0.791
Here, each column came from each population.
You can now use ggpairs()
in GGally
.
GGally::ggpairs(rand_norm)

You can specify what to draw in each upper
, lower
, and diag
side of the plot. This is the default result. In the lower part, you might see the result what you want.
If you are interested in the detail, then you can go to this link GGally. However in this situation I think the default option is enough to solve the problem.