Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>In this way you can automatically create your desired plot with 4 panels.</p> <p>First, the data:</p> <pre><code>scores &lt;- read.table(textConnection(" file max min avg lowest 132 5112.0 6520.0 5728.0 5699.0 133 4720.0 6064.0 5299.0 5277.0 5 4617.0 5936.0 5185.0 5165.0 1 4384.0 5613.0 4917.0 4895.0 1010 5008.0 6291.0 5591.0 5545.0 104 4329.0 5554.0 4858.0 4838.0 105 4636.0 5905.0 5193.0 5165.0 35 4304.0 5578.0 4842.0 4831.0 36 4360.0 5580.0 4891.0 4867.0 37 4444.0 5663.0 4979.0 4952.0 31 4328.0 5559.0 4858.0 4839.0 39 4486.0 5736.0 5031.0 5006.0 32 4334.0 5558.0 4864.0 4843.0 "), header=TRUE) file_vals &lt;- read.table(textConnection(" file avg_vals 133 1.5923 132 1.6351 1010 1.6532 104 1.6824 105 1.6087 39 1.8694 32 1.9934 31 1.9919 37 1.8638 36 1.9691 35 1.9802 1 1.7283 5 1.7637 "), header=TRUE) </code></pre> <p>Both data frames can be merged into a single one:</p> <pre><code>dat &lt;- merge(scores, file_vals, by = "file") </code></pre> <p>Fit:</p> <pre><code>d &lt;- dist(dat$avg_vals, method = "euclidean") fit &lt;- hclust(d, method="ward") groups &lt;- cutree(fit, k=3) cols &lt;- c('red', 'blue', 'green', 'purple', 'orange', 'magenta', 'brown', 'chartreuse4','darkgray','cyan1') </code></pre> <p>Add a column with the colour names (based on the fit):</p> <pre><code>dat$group &lt;- cols[groups] </code></pre> <p>Reshape data from wide to long format:</p> <pre><code>dat_re &lt;- reshape(dat, varying = c("max", "min", "avg", "lowest"), direction = "long", drop = c("file", "avg_vals"), v.names = "value", idvar = "group", times = c("max", "min", "avg", "lowest"), new.row.names = seq(nrow(scores) * 4)) </code></pre> <p>Plot:</p> <pre><code>p &lt;- (ggplot(dat_re ,aes(x = value))) + geom_density(aes(fill = group), alpha=.3) + scale_fill_manual(values=cols) + labs(fill = 'Clusters') + facet_wrap( ~ time) print(p) </code></pre> <p><img src="https://i.stack.imgur.com/qcKjL.png" alt="enter image description here"></p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload