I am struggling with hierarchical or clustering. I have the following time-series and I want to cluster to based on time. Would transpose function work for this?
structure(list(`04:00` = c(0, 0, 0, 0, 0, 0), `04:10` = c(0,
0, 0, 0, 0, 0), `04:20` = c(0, 0, 0, 0, 0, 0), `04:30` = c(0,
0, 0, 0, 0, 0), `04:40` = c(0, 0, 0, 0, 0, 0), `04:50` = c(0,
0, 0, 0, 0, 0), `05:00` = c(0, 0, 0, 0, 0, 0), `05:10` = c(0,
0, 0, 0, 0, 0), `05:20` = c(0, 0, 0, 0, 0, 0), `05:30` = c(0,
0, 0, 0, 0, 0), `05:40` = c(0, 0, 0, 0, 0, 0), `05:50` = c(1,
0, 0, 0, 0, 0), `06:00` = c(1, 0, 0, 0, 0, 0), `06:10` = c(1,
0, 0, 0, 0, 0), `06:20` = c(2, 0, 0, 0, 0, 0), `06:30` = c(0,
0, 0, 0, 0, 0), `06:40` = c(0, 1, 0, 0, 0, 0), `06:50` = c(0,
2, 0, 0, 0, 1), `07:00` = c(0, 0, 0, 0, 0, 2), `07:10` = c(0,
0, 1, 0, 0, 2), `07:20` = c(0, 0, 0, 0, 0, 2), `07:30` = c(0,
0, 1, 0, 0, 0), `07:40` = c(1, 0, 1, 0, 0, 0), `07:50` = c(1,
0, 0, 0, 2, 0), `08:00` = c(1, 0, 0, 0, 0, 0), `08:10` = c(1,
0, 0, 0, 0, 0), `08:20` = c(2, 0, 0, 0, 0, 0), `08:30` = c(2,
0, 0, 0, 0, 0), `08:40` = c(2, 0, 0, 0, 0, 0), `08:50` = c(2,
0, 0, 0, 0, 0), `09:00` = c(0, 0, 0, 0, 0, 0), `09:10` = c(0,
0, 0, 0, 0, 0), `09:20` = c(0, 1, 0, 0, 0, 0), `09:30` = c(0,
1, 0, 2, 0, 0), `09:40` = c(0, 1, 0, 0, 0, 0), `09:50` = c(0,
1, 0, 0, 0, 0), `10:00` = c(0, 0, 0, 0, 0, 0), `10:10` = c(0,
0, 0, 0, 0, 0), `10:20` = c(0, 1, 0, 0, 0, 0), `10:30` = c(0,
1, 0, 0, 0, 0), `10:40` = c(0, 0, 0, 0, 0, 0), `10:50` = c(0,
0, 0, 0, 0, 0), `11:00` = c(2, 0, 0, 1, 0, 0), `11:10` = c(0,
0, 0, 1, 0, 0), `11:20` = c(0, 0, 0, 1, 0, 1), `11:30` = c(0,
0, 0, 1, 0, 1), `11:40` = c(0, 0, 0, 1, 0, 1), `11:50` = c(0,
0, 0, 1, 0, 0), `12:00` = c(0, 0, 0, 1, 2, 0), `12:10` = c(0,
0, 0, 1, 0, 0), `12:20` = c(0, 0, 0, 1, 0, 0), `12:30` = c(0,
0, 0, 1, 0, 0), `12:40` = c(0, 0, 0, 1, 0, 0), `12:50` = c(0,
0, 0, 1, 1, 0), `13:00` = c(0, 0, 0, 0, 1, 0), `13:10` = c(0,
0, 0, 0, 1, 0), `13:20` = c(0, 0, 0, 0, 1, 0), `13:30` = c(0,
0, 0, 0, 1, 0), `13:40` = c(0, 0, 0, 0, 1, 0), `13:50` = c(0,
0, 0, 0, 1, 0), `14:00` = c(0, 0, 0, 0, 1, 0), `14:10` = c(0,
0, 0, 0, 1, 0), `14:20` = c(0, 0, 0, 0, 1, 0), `14:30` = c(0,
0, 0, 0, 1, 0), `14:40` = c(0, 0, 0, 0, 1, 0), `14:50` = c(0,
0, 0, 0, 0, 0), `15:00` = c(0, 0, 0, 0, 0, 0), `15:10` = c(0,
2, 0, 0, 0, 0), `15:20` = c(0, 2, 0, 0, 1, 0), `15:30` = c(0,
2, 0, 0, 1, 1), `15:40` = c(0, 2, 0, 0, 1, 0), `15:50` = c(0,
2, 0, 0, 1, 0), `16:00` = c(0, 2, 0, 0, 1, 0), `16:10` = c(0,
2, 0, 0, 1, 0), `16:20` = c(2, 2, 0, 0, 1, 0), `16:30` = c(2,
2, 0, 0, 1, 2), `16:40` = c(2, 2, 0, 0, 1, 1), `16:50` = c(2,
2, 0, 0, 0, 1), `17:00` = c(0, 2, 0, 0, 2, 0), `17:10` = c(0,
0, 0, 0, 2, 0), `17:20` = c(0, 0, 0, 0, 2, 0), `17:30` = c(0,
0, 0, 0, 2, 0), `17:40` = c(0, 0, 0, 0, 0, 0), `17:50` = c(0,
0, 0, 0, 0, 0), `18:00` = c(0, 2, 0, 0, 0, 2), `18:10` = c(0,
2, 0, 0, 0, 2), `18:20` = c(0, 0, 0, 0, 2, 2), `18:30` = c(0,
0, 0, 0, 0, 2), `18:40` = c(0, 0, 0, 0, 0, 2), `18:50` = c(1,
0, 0, 0, 0, 2), `19:00` = c(1, 0, 0, 1, 1, 0), `19:10` = c(1,
0, 0, 1, 1, 0), `19:20` = c(1, 0, 0, 1, 1, 0), `19:30` = c(1,
0, 1, 1, 1, 0), `19:40` = c(1, 0, 1, 1, 1, 1), `19:50` = c(1,
0, 1, 1, 1, 1), `20:00` = c(0, 0, 1, 1, 1, 1), `20:10` = c(0,
0, 1, 1, 1, 1), `20:20` = c(0, 0, 1, 1, 1, 1), `20:30` = c(0,
1, 2, 1, 1, 1), `20:40` = c(0, 1, 0, 1, 1, 1), `20:50` = c(0,
1, 0, 1, 1, 1), `21:00` = c(0, 1, 0, 1, 1, 1), `21:10` = c(0,
1, 0, 0, 1, 1), `21:20` = c(0, 1, 0, 0, 1, 1), `21:30` = c(0,
1, 1, 0, 1, 1), `21:40` = c(0, 1, 1, 0, 1, 1), `21:50` = c(0,
1, 1, 0, 0, 1), `22:00` = c(0, 1, 1, 0, 0, 0), `22:10` = c(0,
1, 0, 0, 0, 0), `22:20` = c(0, 1, 0, 0, 0, 0), `22:30` = c(0,
1, 0, 0, 0, 0), `22:40` = c(0, 1, 0, 0, 0, 0), `22:50` = c(0,
1, 0, 0, 0, 0), `23:00` = c(0, 0, 0, 0, 1, 0), `23:10` = c(0,
0, 0, 0, 0, 1), `23:20` = c(0, 0, 0, 0, 0, 1), `23:30` = c(0,
0, 0, 0, 0, 1), `23:40` = c(0, 0, 0, 0, 0, 1), `23:50` = c(0,
0, 0, 0, 0, 0), `00:00` = c(0, 0, 0, 0, 0, 0), `00:10` = c(0,
0, 0, 0, 0, 0), `00:20` = c(0, 0, 0, 0, 0, 0), `00:30` = c(0,
0, 0, 0, 0, 0), `00:40` = c(0, 0, 0, 0, 0, 0), `00:50` = c(0,
0, 0, 0, 0, 0), `01:00` = c(0, 0, 0, 0, 0, 0), `01:10` = c(0,
0, 0, 0, 0, 0), `01:20` = c(0, 0, 0, 0, 0, 0), `01:30` = c(0,
0, 0, 0, 0, 0), `01:40` = c(0, 0, 0, 0, 0, 0), `01:50` = c(0,
0, 0, 0, 0, 0), `02:00` = c(0, 0, 0, 0, 0, 0), `02:10` = c(0,
0, 0, 0, 0, 0), `02:20` = c(0, 0, 0, 0, 0, 0), `02:30` = c(0,
0, 0, 0, 0, 0), `02:40` = c(0, 0, 0, 0, 0, 0), `02:50` = c(0,
0, 0, 0, 0, 0), `03:00` = c(0, 0, 0, 0, 0, 0), `03:10` = c(0,
0, 0, 0, 0, 0), `03:20` = c(0, 0, 0, 0, 0, 0), `03:30` = c(0,
0, 0, 0, 0, 0), `03:40` = c(0, 0, 0, 0, 0, 0), `03:50` = c(0,
0, 0, 0, 0, 0)), row.names = c("1", "2", "3", "4", "5", "6"), class = "data.frame")
I managed to run hierarchical clustering but only on cases and not on time
d_distance <- dist(as.matrix(df))
plot(hclust(d_distance))
The plot that I generated
As you can see on the plot the structure end points are indexes - how can I have instead of index time (maybe transpose)? Also I would like to plot time-series cluster separately like below plot. Would dtw be better than hierarchical clustering?
I am trying to run an NMDS on some data, using the metaMDS function in the R vegan package. I've managed to run it with a similar dataframe, but for some reason I'm getting the following error with this one:
>Error in cmdscale(dist, k = k) : NA values not allowed in 'd'
In addition: Warning messages:
1: In distfun(comm, method = distance, ...) :
you have empty rows: their dissimilarities may be meaningless in method “bray”
2: In distfun(comm, method = distance, ...) : missing values in results
As it's a large dataframe, I've put it into a Google sheet here
For context, the rows are samples and the columns are genes, with the value indicating the level of the gene in the sample.
With the NMDS, I want to see how similar the samples are, and from that I understand I've got the data set up correctly.
So I tried running the following;
library(vegan)
NMDS <- metaMDS(NMDS, distance="bray")
where NMDS is the dataframe. This is where I get the above error, and I'm not sure what I've done wrong?
This also happens after I run the following code:
NMDS[is.na(NMDS)] = 0
Any ideas where I'm going wrong?
dput:
structure(list(X1 = c(0, 0, 0, 0, 0, 0), X2 = c(0, 0, 0, 0, 0,
0), X3 = c(0, 0, 0, 0, 0, 0), X4 = c(0, 0, 0, 0, 0, 0), X5 = c(0,
0, 0, 0, 0, 0), X6 = c(0, 28, 161, 688, 0, 0), X7 = c(0, 3, 14,
0, 0, 0), X8 = c(0, 0, 0, 0, 0, 0), X9 = c(3, 0, 2, 2, 0, 0),
X10 = c(12, 78, 602, 303, 900, 0), X11 = c(0, 52, 856, 28,
191, 0), X12 = c(0, 51, 12, 1, 0, 0), X13 = c(0, 0, 0, 0,
0, 0), X14 = c(0, 0, 2, 0, 0, 0), X15 = c(5, 17, 46, 39,
9, 0), X16 = c(5255, 1531, 6790, 3302, 5084, 0), X17 = c(0,
0, 0, 0, 0, 0), X18 = c(0, 0, 15, 0, 0, 0), X19 = c(0, 0,
0, 0, 0, 0), X20 = c(0, 0, 0, 0, 0, 0), X21 = c(0, 0, 0,
0, 0, 0), X22 = c(0, 0, 0, 0, 0, 0), X23 = c(0, 0, 0, 0,
0, 0), X24 = c(0, 0, 44, 0, 0, 0), X25 = c(0, 0, 0, 0, 0,
0), X26 = c(0, 6, 24, 185, 0, 0), X27 = c(0, 0, 0, 0, 0,
0), X28 = c(0, 0, 13, 0, 0, 0), X29 = c(0, 0, 0, 0, 0, 0),
X30 = c(0, 0, 0, 7, 0, 0), X31 = c(0, 0, 0, 0, 0, 0), X32 = c(0,
0, 0, 0, 0, 0), X33 = c(0, 0, 1, 2, 0, 0), X34 = c(0, 0,
0, 0, 0, 0), X35 = c(0, 0, 0, 0, 0, 0), X36 = c(0, 2, 0,
0, 0, 0), X37 = c(0, 0, 0, 0, 0, 0), X38 = c(0, 0, 0, 0,
0, 0), X39 = c(0, 0, 0, 0, 0, 0), X40 = c(0, 0, 0, 0, 0,
0), X41 = c(0, 0, 0, 0, 0, 0), X42 = c(0, 0, 0, 0, 0, 0),
X43 = c(0, 0, 0, 0, 0, 0), X44 = c(0, 0, 0, 0, 0, 0), X45 = c(0,
0, 0, 1, 0, 0), X46 = c(0, 0, 0, 63, 0, 0), X47 = c(0, 0,
0, 0, 0, 0), X48 = c(0, 0, 0, 0, 0, 0), X49 = c(0, 0, 0,
0, 0, 0), X50 = c(0, 0, 0, 0, 0, 0), X51 = c(0, 0, 0, 0,
0, 0), X52 = c(0, 0, 0, 0, 0, 0), X53 = c(0, 0, 0, 1, 0,
0), X54 = c(0, 0, 0, 0, 0, 0), X55 = c(0, 0, 0, 1, 0, 0),
X56 = c(0, 0, 0, 0, 0, 0), X57 = c(0, 0, 3, 0, 0, 0), X58 = c(0,
0, 0, 0, 0, 0), X59 = c(0, 0, 0, 0, 0, 0), X60 = c(0, 0,
0, 0, 0, 0), X61 = c(0, 0, 44, 0, 0, 0), X62 = c(0, 0, 15,
0, 0, 0), X63 = c(0, 0, 347, 0, 0, 0), X64 = c(0, 0, 0, 0,
0, 0), X65 = c(0, 0, 0, 5, 0, 0), X66 = c(0, 0, 0, 0, 0,
0), X67 = c(1, 8, 2, 11, 6, 0), X68 = c(0, 26, 0, 0, 0, 0
), X69 = c(0, 0, 0, 8, 0, 0), X70 = c(0, 0, 0, 13, 0, 0),
X71 = c(0, 0, 0, 0, 0, 0), X72 = c(0, 2, 0, 0, 0, 0), X73 = c(0,
0, 0, 0, 0, 0), X74 = c(341, 74, 0, 0, 0, 0), X75 = c(4,
6, 10, 17, 13, 0), X76 = c(0, 0, 0, 0, 0, 0), X77 = c(0,
0, 0, 0, 0, 0), X78 = c(0, 0, 0, 6, 0, 0), X79 = c(0, 0,
0, 0, 0, 0), X80 = c(0, 0, 0, 0, 0, 0), X81 = c(403, 86,
0, 0, 0, 0), X82 = c(20, 95, 54, 0, 0, 0), X83 = c(0, 2,
0, 1, 0, 0), X84 = c(0, 0, 3, 1, 0, 0), X85 = c(0, 0, 0,
0, 0, 0), X86 = c(40, 132, 39, 0, 1, 0), X87 = c(0, 0, 0,
0, 0, 0), X88 = c(0, 0, 0, 0, 0, 0), X89 = c(0, 0, 0, 0,
0, 0), X90 = c(0, 0, 0, 0, 0, 0), X91 = c(0, 0, 0, 0, 0,
0), X92 = c(0, 7, 0, 0, 0, 0), X93 = c(0, 0, 0, 0, 0, 0),
X94 = c(0, 0, 0, 0, 0, 0), X95 = c(0, 0, 0, 0, 0, 0), X96 = c(0,
0, 0, 0, 0, 0), X97 = c(0, 0, 0, 0, 0, 0), X98 = c(0, 0,
0, 0, 0, 0), X99 = c(0, 0, 0, 0, 0, 0), X100 = c(0, 0, 0,
0, 0, 0), X101 = c(0, 0, 0, 0, 0, 0), X102 = c(0, 8, 0, 1,
0, 0), X103 = c(0, 0, 0, 0, 0, 0), X104 = c(0, 0, 0, 0, 0,
0), X105 = c(0, 0, 0, 0, 0, 0), X106 = c(0, 0, 0, 0, 0, 0
), X107 = c(0, 0, 0, 0, 0, 0), X108 = c(0, 0, 0, 0, 0, 0),
X109 = c(0, 0, 0, 0, 0, 0), X110 = c(0, 0, 0, 0, 0, 0), X111 = c(0,
0, 0, 0, 0, 0), X112 = c(15, 47, 0, 1, 0, 0), X113 = c(0,
0, 0, 0, 0, 0), X114 = c(0, 0, 0, 0, 0, 0), X115 = c(0, 0,
0, 2, 0, 0), X116 = c(43, 0, 0, 1, 1, 0), X117 = c(0, 0,
0, 0, 0, 0), X118 = c(0, 0, 0, 0, 0, 0), X119 = c(0, 0, 0,
0, 0, 0), X120 = c(387, 0, 0, 0, 0, 0), X121 = c(0, 0, 0,
0, 0, 0), X122 = c(342, 1, 0, 72, 0, 0), X123 = c(0, 0, 0,
0, 0, 0), X124 = c(0, 0, 0, 76, 0, 0), X125 = c(0, 0, 0,
0, 0, 0), X126 = c(0, 0, 0, 0, 0, 0), X127 = c(0, 2, 0, 0,
0, 0), X128 = c(0, 0, 0, 0, 0, 0), X129 = c(0, 0, 0, 0, 0,
0), X130 = c(0, 0, 0, 0, 0, 0), X131 = c(0, 0, 0, 0, 0, 0
), X132 = c(0, 0, 0, 0, 0, 0), X133 = c(0, 0, 0, 0, 0, 0),
X134 = c(0, 0, 0, 11, 0, 0), X135 = c(13, 108, 0, 129, 192,
0), X136 = c(0, 0, 0, 0, 0, 0), X137 = c(18, 129, 0, 23,
0, 0), X138 = c(0, 0, 0, 32, 7, 0), X139 = c(1, 0, 0, 10,
0, 0), X140 = c(0, 0, 0, 3, 0, 0), X141 = c(0, 0, 0, 0, 0,
0), X142 = c(0, 0, 0, 14, 0, 0), X143 = c(0, 0, 0, 0, 0,
0), X144 = c(16, 74, 71, 0, 0, 0), X145 = c(0, 0, 0, 0, 392,
0), X146 = c(0, 24, 224, 1, 0, 0), X147 = c(0, 19, 224, 1,
0, 0), X148 = c(0, 13, 253, 0, 0, 0), X149 = c(49, 17, 17,
0, 0, 0), X150 = c(133, 70, 74, 0, 0, 0), X151 = c(0, 0,
0, 0, 0, 0), X152 = c(0, 0, 0, 0, 0, 0), X153 = c(0, 0, 0,
0, 0, 0), X154 = c(0, 0, 0, 0, 0, 0), X155 = c(0, 0, 0, 0,
0, 0), X156 = c(0, 1, 0, 0, 0, 0), X157 = c(0, 0, 0, 0, 0,
0), X158 = c(0, 0, 0, 22, 0, 0), X159 = c(0, 0, 0, 0, 0,
0), X160 = c(0, 0, 0, 10, 0, 0), X161 = c(0, 0, 0, 106, 0,
0), X162 = c(148, 27, 85, 0, 0, 0), X163 = c(0, 0, 0, 0,
0, 0), X164 = c(0, 0, 0, 0, 0, 0), X165 = c(0, 10, 0, 0,
0, 0), X166 = c(0, 5, 0, 0, 0, 0), X167 = c(0, 0, 0, 0, 0,
0), X168 = c(1, 0, 0, 0, 0, 0), X169 = c(0, 7, 0, 0, 0, 0
), X170 = c(0, 0, 0, 2, 0, 0), X171 = c(0, 0, 0, 0, 0, 0),
X172 = c(0, 0, 0, 0, 0, 0), X173 = c(0, 0, 0, 0, 0, 0), X174 = c(0,
0, 0, 0, 0, 0), X175 = c(0, 0, 0, 2, 0, 0), X176 = c(0, 0,
0, 0, 0, 0), X177 = c(0, 0, 0, 212, 0, 0), X178 = c(0, 1,
0, 0, 0, 0), X179 = c(0, 0, 0, 0, 0, 0), X180 = c(0, 0, 0,
0, 0, 0), X181 = c(0, 0, 0, 0, 0, 0), X182 = c(0, 0, 0, 0,
0, 0), X183 = c(0, 0, 0, 0, 0, 0), X184 = c(0, 0, 0, 0, 0,
0), X185 = c(0, 9, 0, 0, 0, 0), X186 = c(0, 0, 0, 0, 0, 0
), X187 = c(0, 0, 0, 0, 0, 0), X188 = c(0, 0, 0, 0, 0, 0),
X189 = c(0, 0, 0, 0, 0, 0), X190 = c(475, 108, 329, 14, 57,
0), X191 = c(0, 0, 8, 0, 0, 0), X192 = c(0, 0, 0, 0, 0, 0
), X193 = c(0, 0, 0, 0, 0, 0), X194 = c(0, 0, 0, 0, 0, 0),
X195 = c(0, 0, 0, 0, 0, 0), X196 = c(0, 0, 0, 0, 0, 0), X197 = c(0,
0, 0, 0, 0, 0), X198 = c(0, 0, 2, 0, 0, 0), X199 = c(0, 0,
0, 0, 0, 0), X200 = c(0, 0, 0, 0, 0, 0), X201 = c(0, 27,
647, 1, 0, 0), X202 = c(0, 0, 0, 0, 0, 0), X203 = c(0, 0,
0, 0, 0, 0), X204 = c(0, 0, 0, 0, 0, 0), X205 = c(251, 41,
58, 0, 1, 0), X206 = c(0, 0, 0, 0, 0, 0), X207 = c(0, 0,
0, 0, 0, 0), X208 = c(0, 0, 0, 0, 0, 0), X209 = c(0, 0, 0,
0, 0, 0), X210 = c(0, 0, 0, 0, 0, 0), X211 = c(0, 0, 0, 0,
0, 0), X212 = c(0, 0, 0, 0, 0, 0), X213 = c(0, 0, 0, 0, 0,
0), X214 = c(0, 0, 0, 0, 0, 0), X215 = c(0, 0, 0, 0, 0, 0
), X216 = c(0, 0, 0, 0, 0, 0), X217 = c(0, 0, 0, 0, 0, 0),
X218 = c(0, 0, 0, 0, 0, 0), X219 = c(0, 0, 0, 0, 0, 0), X220 = c(0,
0, 0, 0, 0, 0), X221 = c(0, 0, 0, 0, 0, 0), X222 = c(0, 0,
0, 0, 0, 0), X223 = c(0, 0, 0, 0, 0, 0), X224 = c(2, 0, 0,
0, 0, 0), X225 = c(0, 0, 0, 0, 0, 0), X226 = c(0, 0, 0, 0,
0, 0), X227 = c(0, 0, 0, 0, 0, 0), X228 = c(0, 0, 0, 0, 0,
0), X229 = c(0, 0, 0, 0, 0, 0), X230 = c(0, 0, 0, 0, 0, 0
), X231 = c(1, 0, 0, 0, 0, 0), X232 = c(0, 0, 0, 0, 0, 0),
X233 = c(0, 0, 0, 0, 0, 0), X234 = c(0, 0, 0, 0, 0, 0), X235 = c(0,
0, 0, 0, 0, 0), X236 = c(0, 0, 0, 0, 0, 0), X237 = c(0, 0,
0, 0, 0, 0), X238 = c(0, 0, 0, 0, 0, 0), X239 = c(0, 0, 0,
0, 0, 0), X240 = c(1, 0, 0, 0, 0, 0), X241 = c(445, 90, 0,
0, 1, 0), X242 = c(1, 70, 0, 0, 0, 0), X243 = c(23, 154,
11, 0, 0, 0), X244 = c(0, 0, 1, 0, 0, 0), X245 = c(174, 250,
192, 6, 0, 0), X246 = c(0, 2, 0, 1, 0, 0), X247 = c(0, 0,
0, 0, 0, 0), X248 = c(0, 0, 0, 0, 0, 0), X249 = c(29, 73,
20, 0, 0, 0), X250 = c(0, 99, 0, 0, 0, 0), X251 = c(20, 66,
4, 0, 0, 0), X252 = c(265, 48, 191, 0, 1, 0), X253 = c(112,
59, 0, 0, 0, 0), X254 = c(0, 3, 3, 0, 0, 0), X255 = c(0,
1, 0, 0, 0, 0), X256 = c(0, 0, 0, 0, 0, 0), X257 = c(0, 2,
0, 0, 0, 0), X258 = c(0, 0, 0, 0, 0, 0), X259 = c(86, 44,
69, 0, 0, 0), X260 = c(0, 0, 0, 0, 0, 0), X261 = c(13, 27,
0, 0, 1, 0), X262 = c(0, 5, 0, 0, 0, 0), X263 = c(0, 0, 0,
0, 0, 0), X264 = c(0, 0, 0, 0, 0, 0), X265 = c(0, 0, 0, 0,
0, 0), X266 = c(0, 0, 0, 0, 0, 0), X267 = c(0, 1, 0, 0, 0,
0), X268 = c(0, 0, 0, 0, 0, 0), X269 = c(0, 0, 0, 0, 0, 0
), X270 = c(0, 0, 0, 0, 0, 0), X271 = c(0, 0, 0, 4, 0, 0),
X272 = c(0, 0, 0, 0, 0, 0), X273 = c(0, 0, 0, 0, 0, 0), X274 = c(0,
0, 0, 0, 0, 0), X275 = c(291, 200, 115, 0, 0, 0), X276 = c(0,
5, 0, 0, 0, 0), X277 = c(0, 0, 0, 0, 0, 0), X278 = c(0, 5,
0, 5, 0, 0), X279 = c(0, 3, 2, 6, 0, 0), X280 = c(0, 0, 28,
0, 0, 0), X281 = c(0, 1, 0, 0, 0, 0), X282 = c(0, 8, 1, 5,
0, 0), X283 = c(0, 3, 0, 1, 0, 0), X284 = c(0, 0, 17, 0,
0, 0), X285 = c(0, 3, 0, 0, 0, 0), X286 = c(0, 0, 0, 0, 0,
0), X287 = c(0, 1, 1, 4, 0, 0), X288 = c(0, 0, 0, 0, 0, 0
), X289 = c(0, 2, 0, 0, 0, 0), X290 = c(0, 0, 0, 0, 0, 0),
X291 = c(0, 0, 0, 0, 0, 0), X292 = c(0, 0, 0, 4, 0, 0), X293 = c(0,
0, 0, 0, 0, 0), X294 = c(38, 10, 72, 0, 0, 0), X295 = c(0,
58, 0, 0, 0, 0), X296 = c(0, 20, 0, 0, 0, 0), X297 = c(69,
4, 39, 0, 1, 0), X298 = c(0, 15, 304, 3, 0, 0), X299 = c(0,
0, 0, 0, 0, 0), X300 = c(0, 6, 0, 0, 0, 0), X301 = c(0, 1,
0, 0, 0, 0), X302 = c(51, 28, 13, 0, 0, 0), X303 = c(96,
149, 28, 0, 0, 0), X304 = c(34, 25, 24, 0, 0, 0), X305 = c(0,
3, 1, 0, 0, 0), X306 = c(0, 3, 7, 0, 0, 0), X307 = c(0, 4,
0, 0, 0, 0), X308 = c(0, 0, 0, 0, 0, 0), X309 = c(0, 0, 35,
1, 0, 0), X310 = c(262, 9, 137, 0, 0, 0), X311 = c(3, 15,
0, 2, 9, 0), X312 = c(445, 139, 353, 48, 16, 0), X313 = c(0,
0, 0, 0, 0, 0), X314 = c(0, 0, 0, 0, 0, 0), X315 = c(0, 0,
0, 0, 0, 0), X316 = c(0, 0, 0, 0, 0, 0), X317 = c(0, 0, 0,
0, 0, 0), X318 = c(0, 0, 0, 0, 0, 0), X319 = c(0, 0, 0, 0,
0, 0), X320 = c(62, 138, 36, 0, 0, 0), X321 = c(3, 0, 0,
0, 0, 0), X322 = c(0, 0, 0, 0, 0, 0), X323 = c(0, 13, 0,
0, 0, 0), X324 = c(0, 0, 0, 0, 0, 0), X325 = c(142, 0, 104,
0, 0, 0), X326 = c(0, 2, 0, 0, 0, 0), X327 = c(56, 35, 101,
0, 0, 0), X328 = c(0, 0, 0, 10, 0, 0), X329 = c(0, 0, 0,
0, 0, 0), X330 = c(0, 2, 0, 0, 0, 0), X331 = c(259, 27, 107,
0, 2, 0), X332 = c(0, 0, 0, 0, 0, 0), X333 = c(0, 7, 0, 0,
0, 0), X334 = c(0, 0, 0, 0, 0, 0), X335 = c(98, 39, 95, 0,
0, 0), X336 = c(0, 0, 1, 0, 0, 0), X337 = c(0, 0, 0, 0, 0,
0), X338 = c(141, 28, 85, 0, 0, 0), X339 = c(15, 14, 20,
0, 0, 0), X340 = c(0, 6, 0, 0, 0, 0), X341 = c(0, 0, 0, 0,
0, 0), X342 = c(0, 2, 0, 0, 0, 0), X343 = c(0, 0, 0, 0, 0,
0), X344 = c(0, 0, 0, 0, 0, 0), X345 = c(0, 10, 232, 0, 0,
0), X346 = c(0, 4, 0, 0, 0, 0), X347 = c(0, 0, 0, 0, 0, 0
), X348 = c(0, 0, 0, 0, 0, 0), X349 = c(0, 0, 0, 0, 0, 0),
X350 = c(0, 0, 0, 0, 0, 0), X351 = c(0, 0, 0, 0, 0, 0), X352 = c(0,
0, 0, 0, 0, 0), X353 = c(0, 0, 0, 0, 4, 0), X354 = c(0, 0,
0, 0, 0, 0), X355 = c(0, 0, 0, 0, 1, 0), X356 = c(0, 0, 0,
0, 0, 0), X357 = c(0, 0, 0, 0, 0, 0), X358 = c(0, 0, 0, 0,
0, 0), X359 = c(0, 0, 0, 0, 0, 0), X360 = c(0, 0, 0, 0, 0,
0), X361 = c(0, 0, 0, 0, 0, 0), X362 = c(0, 0, 0, 0, 0, 0
), X363 = c(0, 0, 0, 0, 0, 0), X364 = c(0, 0, 0, 0, 2, 0),
X365 = c(0, 0, 0, 0, 0, 0), X366 = c(0, 0, 0, 0, 0, 0), X367 = c(0,
0, 0, 0, 0, 0), X368 = c(0, 0, 0, 0, 0, 0), X369 = c(0, 0,
0, 17, 0, 0), X370 = c(0, 0, 0, 0, 0, 0), X371 = c(0, 0,
0, 0, 0, 0), X372 = c(0, 0, 0, 0, 0, 0), X373 = c(0, 0, 0,
0, 0, 0), X374 = c(0, 0, 0, 0, 0, 0), X375 = c(0, 0, 0, 0,
0, 0), X376 = c(0, 0, 1, 0, 0, 0), X377 = c(0, 0, 0, 0, 0,
0), X378 = c(0, 0, 0, 0, 0, 0), X379 = c(0, 0, 0, 0, 0, 0
), X380 = c(0, 0, 0, 0, 0, 0), X381 = c(0, 0, 0, 0, 0, 0),
X382 = c(0, 0, 0, 0, 0, 0), X383 = c(0, 51, 0, 0, 0, 0),
X384 = c(0, 0, 0, 0, 0, 0), X385 = c(7, 0, 0, 11, 1, 0),
X386 = c(0, 0, 0, 0, 0, 0), X387 = c(0, 0, 1, 0, 0, 0), X388 = c(0,
0, 0, 0, 0, 0), X389 = c(0, 0, 0, 0, 0, 0), X390 = c(0, 5,
0, 0, 0, 0), X391 = c(0, 0, 0, 0, 0, 0), X392 = c(0, 0, 0,
0, 0, 0), X393 = c(2, 16, 0, 0, 0, 0), X394 = c(0, 6, 88,
0, 0, 0), X395 = c(0, 14, 136, 1, 0, 0), X396 = c(0, 41,
350, 2, 0, 0), X397 = c(0, 0, 0, 0, 0, 0), X398 = c(20, 413,
0, 12, 3, 0), X399 = c(0, 0, 0, 0, 0, 0), X400 = c(0, 3,
0, 0, 0, 0), X401 = c(0, 0, 0, 0, 0, 0), X402 = c(0, 2, 0,
0, 0, 0), X403 = c(0, 2, 0, 0, 0, 0), X404 = c(0, 0, 0, 0,
0, 0), X405 = c(0, 0, 0, 0, 0, 0), X406 = c(0, 0, 0, 0, 0,
0), X407 = c(0, 0, 39, 1, 0, 0), X408 = c(10, 73, 31, 0,
0, 0), X409 = c(0, 11, 0, 0, 0, 0), X410 = c(68, 58, 66,
1, 0, 0), X411 = c(4, 32, 3, 0, 0, 0), X412 = c(8, 66, 39,
0, 0, 0), X413 = c(0, 0, 0, 0, 0, 0), X414 = c(2, 53, 7,
0, 0, 0), X415 = c(120, 90, 109, 0, 0, 0), X416 = c(0, 80,
0, 0, 0, 0), X417 = c(62, 79, 24, 0, 0, 0), X418 = c(58,
156, 30, 0, 0, 0), X419 = c(72, 138, 50, 2, 0, 0), X420 = c(0,
0, 0, 0, 0, 0), X421 = c(0, 0, 0, 0, 0, 0), X422 = c(36,
143, 43, 0, 0, 0), X423 = c(0, 0, 0, 0, 0, 0), X424 = c(0,
0, 0, 0, 0, 0), X425 = c(0, 5, 0, 0, 0, 0), X426 = c(12,
109, 0, 18, 26, 0), X427 = c(0, 0, 0, 0, 0, 0), X428 = c(0,
0, 0, 0, 0, 0), X429 = c(0, 3, 0, 0, 0, 0), X430 = c(0, 0,
362, 0, 0, 0), X431 = c(0, 0, 0, 0, 0, 0), X432 = c(0, 0,
685, 0, 0, 0), X433 = c(0, 0, 0, 0, 0, 0), X434 = c(0, 0,
0, 0, 0, 0), X435 = c(0, 0, 0, 0, 0, 0), X436 = c(0, 0, 0,
0, 0, 0), X437 = c(0, 0, 15, 8, 0, 0), X438 = c(0, 0, 184,
0, 0, 0), X439 = c(0, 0, 0, 0, 0, 0), X440 = c(0, 0, 0, 0,
0, 0), X441 = c(0, 0, 0, 0, 0, 0), X442 = c(0, 0, 0, 0, 0,
0), X443 = c(0, 0, 0, 0, 0, 0), X444 = c(0, 6, 0, 0, 0, 0
), X445 = c(0, 0, 0, 0, 0, 0), X446 = c(0, 1, 1, 4, 0, 0),
X447 = c(0, 3, 0, 0, 0, 0), X448 = c(0, 1, 0, 0, 0, 0), X449 = c(616,
28, 368, 0, 0, 0), X450 = c(0, 0, 1, 0, 0, 0), X451 = c(4098,
2120, 3788, 2663, 3524, 0), X452 = c(0, 0, 0, 0, 0, 0), X453 = c(0,
66, 0, 0, 0, 0), X454 = c(0, 9, 0, 0, 0, 0), X455 = c(0,
1, 0, 0, 0, 0), X456 = c(0, 5, 0, 0, 0, 0), X457 = c(57,
111, 36, 0, 0, 0), X458 = c(0, 0, 0, 0, 0, 0), X459 = c(0,
54, 68, 0, 0, 0), X460 = c(0, 0, 0, 0, 0, 0), X461 = c(0,
0, 0, 0, 0, 0), X462 = c(0, 0, 0, 0, 0, 0), X463 = c(0, 0,
0, 0, 0, 0), X464 = c(0, 0, 0, 0, 0, 0), X465 = c(0, 0, 0,
0, 0, 0), X466 = c(0, 0, 0, 0, 0, 0), X467 = c(0, 1, 0, 2,
0, 0), X468 = c(48, 79, 52, 0, 0, 0), X469 = c(24, 244, 178,
0, 0, 0), X470 = c(24, 28, 13, 0, 0, 0), X471 = c(0, 0, 0,
0, 0, 0), X472 = c(96, 52, 45, 0, 0, 0), X473 = c(0, 0, 0,
102, 0, 0), X474 = c(196, 82, 130, 0, 0, 0), X475 = c(106,
30, 33, 0, 0, 0), X476 = c(12, 21, 22, 0, 0, 0), X477 = c(0,
0, 0, 0, 172, 0), X478 = c(0, 28, 280, 0, 0, 0), X479 = c(0,
27, 310, 0, 0, 0), X480 = c(0, 32, 366, 0, 0, 0), X481 = c(0,
7, 0, 0, 0, 0), X482 = c(0, 22, 0, 0, 0, 0), X483 = c(0,
1, 0, 0, 0, 0), X484 = c(0, 13, 0, 0, 0, 0), X485 = c(0,
2, 0, 0, 0, 0), X486 = c(0, 16, 0, 0, 0, 0), X487 = c(0,
6, 0, 0, 0, 0), X488 = c(0, 8, 0, 0, 0, 0), X489 = c(0, 20,
0, 0, 0, 0), X490 = c(0, 3, 0, 0, 0, 0), X491 = c(0, 14,
0, 0, 0, 0), X492 = c(0, 4, 0, 0, 0, 0), X493 = c(0, 2, 0,
0, 0, 0), X494 = c(0, 5, 0, 0, 0, 0), X495 = c(0, 1, 0, 0,
0, 0), X496 = c(0, 4, 0, 0, 0, 0), X497 = c(0, 15, 0, 0,
0, 0), X498 = c(0, 0, 0, 0, 0, 0), X499 = c(0, 7, 0, 0, 0,
0), X500 = c(0, 13, 0, 0, 0, 0), X501 = c(0, 11, 0, 0, 0,
0), X502 = c(0, 7, 0, 0, 0, 0), X503 = c(0, 4, 0, 0, 0, 0
), X504 = c(0, 0, 0, 0, 0, 0), X505 = c(0, 7, 0, 0, 0, 0),
X506 = c(0, 1, 0, 0, 0, 0), X507 = c(0, 1, 0, 0, 0, 0), X508 = c(0,
0, 0, 1, 0, 0), X509 = c(0, 6, 0, 0, 0, 0), X510 = c(0, 0,
0, 0, 0, 0), X511 = c(0, 2, 0, 0, 0, 0), X512 = c(0, 1, 0,
0, 0, 0), X513 = c(0, 14, 0, 0, 0, 0), X514 = c(0, 3, 0,
0, 0, 0), X515 = c(237, 171, 188, 0, 0, 0), X516 = c(291,
222, 163, 0, 0, 0), X517 = c(5, 36, 9, 0, 0, 0), X518 = c(5,
102, 0, 0, 0, 0), X519 = c(0, 0, 0, 0, 0, 0), X520 = c(0,
0, 0, 0, 0, 0), X521 = c(0, 0, 0, 0, 0, 0), X522 = c(96,
69, 109, 0, 0, 0), X523 = c(236, 0, 118, 0, 1, 0), X524 = c(0,
44, 0, 0, 0, 0), X525 = c(0, 0, 0, 0, 0, 0), X526 = c(0,
0, 0, 0, 0, 0), X527 = c(0, 0, 0, 0, 0, 0), X528 = c(0, 0,
0, 0, 0, 0), X529 = c(0, 62, 15, 0, 0, 0), X530 = c(4, 183,
16, 0, 0, 0), X531 = c(3, 187, 19, 0, 0, 0), X532 = c(197,
79, 64, 0, 0, 0), X533 = c(27, 255, 25, 0, 0, 0), X534 = c(0,
2, 0, 0, 0, 0), X535 = c(0, 20, 0, 0, 0, 0), X536 = c(0,
1, 0, 0, 0, 0), X537 = c(0, 10, 0, 0, 0, 0), X538 = c(0,
1, 0, 0, 0, 0), X539 = c(0, 4, 0, 0, 0, 0), X540 = c(0, 0,
0, 0, 0, 0), X541 = c(0, 6, 0, 0, 0, 0), X542 = c(0, 1, 0,
0, 0, 0), X543 = c(0, 12, 113, 0, 0, 0), X544 = c(0, 77,
990, 0, 0, 0), X545 = c(6, 27, 14, 0, 0, 0), X546 = c(0,
0, 0, 0, 0, 0), X547 = c(0, 0, 0, 0, 0, 0), X548 = c(0, 0,
0, 0, 0, 0), X549 = c(0, 0, 0, 0, 0, 0), X550 = c(0, 0, 0,
0, 0, 0), X551 = c(0, 0, 0, 0, 0, 0), X552 = c(0, 0, 0, 0,
0, 0), X553 = c(301, 0, 0, 0, 0, 0), X554 = c(444, 148, 305,
0, 0, 0), X555 = c(0, 0, 0, 0, 0, 0), X556 = c(0, 2, 2, 0,
0, 0), X557 = c(0, 0, 0, 0, 0, 0), X558 = c(0, 1, 0, 0, 0,
0), X559 = c(0, 0, 0, 0, 0, 0), X560 = c(0, 0, 0, 0, 0, 0
), X561 = c(0, 3, 4, 6, 1, 0), X562 = c(120, 77, 26, 0, 0,
0), X563 = c(0, 3, 628, 0, 0, 0), X564 = c(709, 104, 0, 0,
0, 0), X565 = c(0, 0, 0, 0, 0, 0), X566 = c(95, 59, 581,
175, 1219, 0), X567 = c(0, 0, 0, 0, 13, 0), X568 = c(26,
7, 0, 26, 39, 0), X569 = c(18, 33, 0, 35, 36, 0), X570 = c(0,
2, 41, 39, 1, 0), X571 = c(0, 8, 47, 97, 1, 0), X572 = c(216,
291, 52, 279, 688, 0), X573 = c(198, 504, 0, 5, 0, 0), X574 = c(0,
0, 0, 0, 0, 0), X575 = c(110, 102, 895, 254, 1682, 0), X576 = c(1,
2, 0, 0, 0, 0), X577 = c(10, 18, 0, 0, 0, 0), X578 = c(8,
40, 0, 0, 0, 0), X579 = c(0, 0, 0, 0, 0, 0), X580 = c(0,
0, 0, 0, 0, 0), X581 = c(0, 0, 0, 0, 0, 0), X582 = c(0, 0,
0, 0, 0, 0), X583 = c(0, 0, 216, 0, 0, 0), X584 = c(0, 0,
0, 0, 0, 0), X585 = c(0, 0, 0, 0, 0, 0), X586 = c(0, 0, 0,
0, 0, 0), X587 = c(0, 0, 0, 0, 0, 0), X588 = c(0, 0, 0, 0,
0, 0), X589 = c(0, 0, 0, 0, 0, 0), X590 = c(0, 0, 0, 0, 0,
0), X591 = c(31, 32, 0, 52, 213, 0), X592 = c(0, 0, 12, 0,
0, 0), X593 = c(0, 0, 0, 0, 0, 0), X594 = c(28, 77, 21, 0,
0, 0), X595 = c(0, 0, 0, 0, 0, 0), X596 = c(0, 0, 0, 0, 0,
0)), row.names = c(NA, -6L), class = c("tbl_df", "tbl", "data.frame"
))
You have some rows in NMDS that contain all 0 values which apparently doesn't work with metaMDS.
You can remove rows containing all values == 0 using dplyr:
library(dplyr)
NMDS <- NMDS %>%
filter_all(any_vars(. != 0))
NMDS <- metaMDS(NMDS, distance="bray")
I have plotted a barchart showing mortality rates for municipalities(MUN_RESID) for all months between 08-2005 and 12-2015. Since the data frame is so big, the barchart is not very clear, e.g. one cannot read municipality ids on the x-axis and can't see different coloring for the respective months. I would like to have a barchart more clear, so that one can see id's on the x-axis and the coloring of the bar, if possible.
Thank you very much for your help.
Unfortunately, I am new to R and therefore cannot add a screenshot directly of the barchart directly, but there is a link provided after the code. Also, maybe there are some of you with some general advise on how to handle such issues with a barchart. I have to leave all data within one chart, so splitting the data is no option, unfortunately.
This is what the sample looks like:
MUN_RESID X08.2005_P X09.2005_P X10.2005_P X11.2005_P X12.2005_P
1 120043 0.00000000 0.22382438 0.02797805 0.00000000 0.00000000
2 150775 0.00000000 0.02475672 0.00000000 0.00000000 0.00000000
3 170025 0.00000000 0.00000000 0.00000000 0.04305349 0.00000000
4 170382 0.04510756 0.00000000 0.00000000 0.00000000 0.00000000
5 171180 0.00000000 0.04180602 0.00000000 0.00000000 0.00000000
6 171525 0.04113143 0.00000000 0.00000000 0.00000000 0.00000000
7 172025 0.00000000 0.00000000 0.00000000 0.00000000 0.03480216
until 2015
X07.2015_P X08.2015_P X09.2015_P X10.2015_P X11.2015_P X12.2015_P
1 0 0.05595610 0 0 0 0.00000000
2 0 0.00000000 0 0 0 0.02475672
3 0 0.04305349 0 0 0 0.00000000
4 0 0.00000000 0 0 0 0.00000000
5 0 0.00000000 0 0 0 0.00000000
6 0 0.00000000 0 0 0 0.00000000
7 NA NA NA NA NA NA
[ reached 'max' / getOption("max.print") -- omitted 3 rows ]
==X==============================================================X==
Copy+Paste this part. (If on a Mac, it is already copied!)
==X==============================================================X==
months_total_f052 <- structure(list(MUN_RESID = structure(c(1L, 2L, 3L, 4L, 5L, 6L,7L, 171L, 172L, 173L), .Label = c("120043", "150775", "170025","170382", "171180", "171525", "172025", "220080", "220157", "220198","220207", "220360", "220860", "220960", "220975", "221010", "221037","240960", "241380", "241430", "241490", "250073", "250390", "251060","251380", "251520", "251560", "251570", "280500", "280690", "280730","310070", "310310", "310360", "310610", "310700", "310980", "311220","311470", "311620", "312150", "312190", "312460", "312737", "312790","314010", "314130", "314420", "314570", "314660", "314750", "315727","315870", "315970", "316310", "316490", "316590", "316805", "350075","350150", "350730", "350770", "351330", "351385", "351420", "351492","351495", "351610", "351800", "352060", "352540", "352580", "352885","353100", "353320", "353330", "353450", "354030", "354165", "354450","354765", "354830", "355200", "355460", "355520", "355530", "355570","410115", "410185", "410322", "411065", "411230", "411260", "411650","411729", "411740", "411845", "411925", "412030", "412033", "412420","420055", "420208", "420243", "420515", "420535", "420555", "421020","421085", "421315", "421568", "421590", "430045", "430047", "430057","430185", "430215", "430237", "430462", "430495", "430583", "430597","430637", "430786", "430980", "431036", "431041", "431065", "431127","431164", "431173", "431179", "431235", "431261", "431300", "431301","431308", "431310", "431335", "431346", "431407", "431455", "431477","431507", "431514", "431642", "431643", "431805", "431846", "431849","431861", "431935", "431937", "432045", "432235", "432252", "432285","432320", "432360", "500797", "510100", "510120", "510617", "510729","510810", "520120", "520360", "520393", "520710", "521015", "521200","521945", "522157"), class = "factor"), X08.2005_P = c(0, 0,0, 0.0451075641915337, 0, 0.0411314307409985, 0, 0, 0, 0), X09.2005_P = c(0.223824383944905,0.0247567176401135, 0, 0, 0.0418060200668896, 0, 0, 0.0322436628801032,0.0314032417808054, 0), X10.2005_P = c(0.0279780479931131, 0,0, 0, 0, 0, 0, 0, 0, 0), X11.2005_P = c(0, 0, 0.0430534856764365,0, 0, 0, 0, 0, 0, 0), X12.2005_P = c(0, 0, 0, 0, 0, 0, 0.0348021630882904,0, 0, 0.0329205601559928), X01.2006_P = c(0, 0.0247567176401135,0, 0, 0, 0, 0, 0, 0, 0), X02.2006_P = c(0.0279780479931131, 0,0, 0, 0, 0, 0, 0.0322436628801032, 0.0314032417808054, 0.0329205601559928), X03.2006_P = c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0), X04.2006_P = c(0,0, 0, 0, 0.0418060200668896, 0, 0, 0.0322436628801032, 0, 0),X05.2006_P = c(0.0279780479931131, 0, 0, 0, 0, 0, 0, 0, 0.0314032417808054,0), X06.2006_P = c(0, 0, 0.0430534856764365, 0.0451075641915337,0, 0.0411314307409985, 0, 0, 0, 0), X07.2006_P = c(0.0559560959862262,0, 0.0430534856764365, 0, 0, 0, 0, 0, 0, 0), X08.2006_P = c(0.0559560959862262,0, 0, 0, 0, 0, 0, 0.0322436628801032, 0, 0), X09.2006_P = c(0.0559560959862262,0, 0, 0, 0, 0, 0, 0, 0, 0), X10.2006_P = c(0.0279780479931131,0, 0, 0, 0, 0, 0, 0, 0, 0), X11.2006_P = c(0.0559560959862262,0, 0, 0, 0, 0, 0.0696043261765808, 0, 0, 0), X12.2006_P = c(0,0, 0, 0, 0, 0, 0.0348021630882904, 0, 0, 0.0329205601559928), X01.2007_P = c(0, 0, 0, 0.0451075641915337, 0, 0, 0, 0,0, 0), X02.2007_P = c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0), X03.2007_P = c(0,0, 0, 0, 0, 0, 0, 0, 0, 0), X04.2007_P = c(0, 0.0247567176401135,0, 0, 0, 0, 0.0696043261765808, 0, 0, 0), X05.2007_P = c(0.0279780479931131,0, 0, 0, 0, 0, 0, 0, 0, 0), X06.2007_P = c(0, 0, 0, 0, 0,0, 0, 0, 0.0314032417808054, 0), X07.2007_P = c(0, 0, 0.0430534856764365,0.0451075641915337, 0, 0.0411314307409985, 0, 0, 0, 0.0329205601559928), X08.2007_P = c(0, 0, 0, 0, 0.0418060200668896, 0, 0, 0.0322436628801032,0, 0), X09.2007_P = c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0), X10.2007_P = c(0,0, 0, 0, 0, 0, 0, 0, 0, 0), X11.2007_P = c(0, 0, 0, 0, 0,0, 0, 0, 0, 0), X12.2007_P = c(0, 0, 0, 0, 0, 0, 0, 0, 0,0), X01.2008_P = c(0, 0, 0, 0.0451075641915337, 0, 0, 0,0, 0, 0), X02.2008_P = c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0), X03.2008_P = c(0.0279780479931131,0.0247567176401135, 0, 0, 0, 0, 0, 0, 0, 0), X04.2008_P = c(0,0, 0, 0.0451075641915337, 0.0418060200668896, 0.0411314307409985,0.0348021630882904, 0, 0, 0), X05.2008_P = c(0, 0, 0, 0,0, 0, 0, 0, 0, 0), X06.2008_P = c(0.0559560959862262, 0,0.0430534856764365, 0, 0, 0, 0, 0, 0, 0), X07.2008_P = c(0.0279780479931131,0, 0, 0, 0, 0, 0, 0, 0, 0), X08.2008_P = c(0.0279780479931131,0, 0, 0, 0, 0, 0, 0, 0, 0), X09.2008_P = c(0.0279780479931131,0, 0, 0, 0, 0, 0, 0.0322436628801032, 0, 0.0329205601559928), X10.2008_P = c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0), X11.2008_P = c(0,0, 0, 0, 0, 0, 0, 0, 0.0314032417808054, 0), X12.2008_P = c(0,0, 0, 0, 0, 0, 0.0348021630882904, 0, 0, 0), X01.2009_P = c(0,0, 0, 0.0451075641915337, 0, 0, 0, 0, 0, 0), X02.2009_P = c(0,0, 0, 0, 0, 0, 0.0348021630882904, 0, 0, 0), X03.2009_P = c(0,0, 0, 0, 0, 0, 0, 0, 0, 0), X04.2009_P = c(0, 0, 0, 0, 0,0, 0, 0, 0, 0), X05.2009_P = c(0, 0, 0, 0, 0.0418060200668896,0, 0, 0, 0, 0), X06.2009_P = c(0, 0, 0.0430534856764365,0, 0, 0, 0, 0, 0, 0), X07.2009_P = c(0.0279780479931131,0.0247567176401135, 0, 0, 0, 0, 0, 0, 0.0314032417808054,0), X08.2009_P = c(0, 0, 0, 0, 0, 0.0411314307409985, 0,0, 0, 0), X09.2009_P = c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0.0329205601559928), X10.2009_P = c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0), X11.2009_P = c(0.0279780479931131,0, 0, 0, 0, 0, 0, 0.0322436628801032, 0, 0), X12.2009_P = c(0,0, 0, 0, 0, 0, 0, 0, 0.0314032417808054, 0), X01.2010_P = c(0,0, 0, 0, 0, 0, 0, 0, 0, 0), X02.2010_P = c(0, 0, 0, 0, 0,0, 0, 0, 0, 0), X03.2010_P = c(0, 0, 0, 0, 0, 0, 0, 0, 0,0), X04.2010_P = c(0.0279780479931131, 0, 0, 0, 0, 0, 0,0, 0, 0), X05.2010_P = c(0, 0.049513435280227, 0, 0, 0, 0,0, 0, 0.0314032417808054, 0), X06.2010_P = c(0, 0, 0, 0,0.0418060200668896, 0, 0, 0, 0, 0), X07.2010_P = c(0, 0,0, 0.0451075641915337, 0, 0, 0, 0, 0, 0), X08.2010_P = c(0,0, 0, 0, 0, 0, 0, 0, 0, 0), X09.2010_P = c(0, 0, 0, 0, 0,0.0822628614819971, 0, 0, 0, 0), X10.2010_P = c(0, 0, 0,0, 0, 0, 0, 0.0322436628801032, 0, 0), X11.2010_P = c(0,0, 0, 0, 0, 0, 0.0348021630882904, 0, 0, 0), X12.2010_P = c(0,0, 0.086106971352873, 0, 0, 0, 0, 0, 0, 0.0329205601559928), X01.2011_P = c(0.0279780479931131, 0, 0, 0, 0, 0.0411314307409985,0, 0, 0, 0), X02.2011_P = c(0, 0.0247567176401135, 0, 0,0, 0, 0, 0.0322436628801032, 0, 0), X03.2011_P = c(0, 0,0, 0, 0.0418060200668896, 0, 0, 0, 0, 0), X04.2011_P = c(0,0, 0, 0.0451075641915337, 0, 0, 0, 0, 0.0314032417808054,0), X05.2011_P = c(0, 0, 0, 0, 0, 0.0411314307409985, 0.0348021630882904,0, 0, 0), X06.2011_P = c(0, 0, 0.0430534856764365, 0, 0,0, 0, 0, 0, 0), X07.2011_P = c(0, 0, 0, 0, 0, 0, 0, 0, 0,0.0658411203119856), X08.2011_P = c(0, 0, 0, 0, 0, 0, 0,0, 0, 0), X09.2011_P = c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0), X10.2011_P = c(0,0, 0, 0, 0, 0, 0, 0, 0, 0), X11.2011_P = c(0, 0, 0, 0, 0,0, 0, 0, 0, 0), X12.2011_P = c(0, 0, 0, 0, 0, 0, 0, 0, 0,0), X01.2012_P = c(0, 0.0247567176401135, 0, 0, 0, 0, 0,0, 0, 0.0329205601559928), X02.2012_P = c(0, 0.0742701529203405,0, 0, 0, 0.0411314307409985, 0, 0, 0, 0), X03.2012_P = c(0,0, 0, 0.0451075641915337, 0, 0, 0, 0, 0, 0), X04.2012_P = c(0,0, 0, 0.0902151283830673, 0, 0, 0, 0, 0, 0), X05.2012_P = c(0,0, 0.0430534856764365, 0, 0, 0, 0, 0, 0, 0), X06.2012_P = c(0,0, 0, 0, 0.0836120401337793, 0, 0, 0, 0.0314032417808054,0), X07.2012_P = c(0, 0, 0, 0, 0.0418060200668896, 0, 0,0, 0, 0), X08.2012_P = c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0), X09.2012_P = c(0,0, 0, 0, 0, 0, 0, 0.0322436628801032, 0, 0), X10.2012_P = c(0,0, 0, 0.0451075641915337, 0, 0, 0, 0, 0.0628064835616107,0), X11.2012_P = c(0, 0, 0, 0, 0, 0, 0.0348021630882904,0, 0, 0), X12.2012_P = c(0.0279780479931131, 0, 0, 0, 0,0, 0, 0, 0, 0), X01.2013_P = c(0, 0, 0, 0, 0, 0, NA, 0, 0,NA), X02.2013_P = c(0.0279780479931131, 0, 0, 0, 0, 0, NA,0, 0, NA), X03.2013_P = c(0, 0, 0.0430534856764365, 0.0451075641915337,0, 0, NA, 0, 0, NA), X04.2013_P = c(0, 0, 0, 0, 0, 0.0411314307409985,NA, 0, 0, NA), X05.2013_P = c(0, 0, 0, 0, 0, 0, NA, 0, 0,NA), X06.2013_P = c(0.0279780479931131, 0, 0, 0, 0, 0, NA,0, 0, NA), X07.2013_P = c(0, 0, 0, 0, 0, 0, NA, 0, 0, NA),X08.2013_P = c(0, 0, 0, 0, 0, 0, NA, 0.0322436628801032,0.0314032417808054, NA), X09.2013_P = c(0.0279780479931131,0.049513435280227, 0, 0, 0.0418060200668896, 0, NA, 0.0322436628801032,0, NA), X10.2013_P = c(0.0279780479931131, 0, 0, 0, 0, 0,NA, 0, 0, NA), X11.2013_P = c(0, 0, 0, 0, 0, 0, NA, 0, 0,NA), X12.2013_P = c(0, 0, 0, 0, 0, 0, NA, 0, 0, NA), X01.2014_P = c(0,0, 0, 0, 0.0418060200668896, 0.0411314307409985, NA, 0, 0,NA), X02.2014_P = c(0, 0, 0, 0, 0, 0, NA, 0, 0, NA), X03.2014_P = c(0,0, 0, 0, 0, 0, NA, 0, 0, NA), X04.2014_P = c(0, 0, 0, 0,0, 0, NA, 0, 0, NA), X05.2014_P = c(0, 0, 0.0430534856764365,0, 0, 0, NA, 0.0322436628801032, 0.0314032417808054, NA),X06.2014_P = c(0, 0, 0, 0, 0, 0, NA, 0, 0, NA), X07.2014_P = c(0,0, 0, 0, 0, 0, NA, 0, 0, NA), X08.2014_P = c(0, 0, 0, 0,0, 0, NA, 0, 0, NA), X09.2014_P = c(0.0279780479931131, 0.0247567176401135,0, 0, 0, 0, NA, 0, 0, NA), X10.2014_P = c(0, 0.0247567176401135,0, 0.0451075641915337, 0, 0, NA, 0, 0, NA), X11.2014_P = c(0,0, 0, 0, 0, 0, NA, 0, 0, NA), X12.2014_P = c(0, 0.0247567176401135,0, 0, 0, 0, NA, 0.0644873257602064, 0, NA), X01.2015_P = c(0,0, 0, 0, 0, 0, NA, 0, 0, NA), X02.2015_P = c(0, 0, 0, 0,0, 0, NA, 0, 0, NA), X03.2015_P = c(0, 0, 0, 0, 0, 0, NA,0, 0, NA), X04.2015_P = c(0, 0, 0, 0.0451075641915337, 0.0418060200668896,0.0822628614819971, NA, 0, 0, NA), X05.2015_P = c(0, 0, 0,0, 0, 0, NA, 0, 0, NA), X06.2015_P = c(0, 0.0247567176401135,0, 0, 0, 0, NA, 0, 0, NA), X07.2015_P = c(0, 0, 0, 0, 0,0, NA, 0, 0, NA), X08.2015_P = c(0.0559560959862262, 0, 0.0430534856764365,0, 0, 0, NA, 0, 0.0314032417808054, NA), X09.2015_P = c(0,0, 0, 0, 0, 0, NA, 0, 0, NA), X10.2015_P = c(0, 0, 0, 0,0, 0, NA, 0, 0, NA), X11.2015_P = c(0, 0, 0, 0, 0, 0, NA,0.0322436628801032, 0, NA), X12.2015_P = c(0, 0.0247567176401135,0, 0, 0, 0, NA, 0, 0, NA)), row.names = c(1L, 2L, 3L, 4L,5L, 6L, 7L, 171L, 172L, 173L), class = "data.frame")
==X==============================================================X==
I used this code for plotting:
months_total_f052$MUN_RESID <- as.factor(months_total_f052$MUN_RESID)
barchart(months_total_f052, X08.2005_P+X09.2005_P+X10.2005_P+X11.2005_P+X12.2005_P+X01.2006_P+X02.2006_P+X03.2006_P+X04.2006_P+X05.2006_P+X06.2006_P+X07.2006_P+X08.2006_P+X09.2006_P+X10.2006_P+X11.2006_P+X12.2006_P+
X01.2007_P+X02.2007_P+X03.2007_P+X04.2007_P+X05.2007_P+X06.2007_P+X07.2007_P+X08.2007_P+X09.2007_P+X10.2007_P+X11.2007_P+X12.2007_P+
X01.2008_P+X02.2008_P+X03.2008_P+X04.2008_P+X05.2008_P+X06.2008_P+X07.2008_P+X08.2008_P+X09.2008_P+X10.2008_P+X11.2008_P+X12.2008_P+
X01.2009_P+X02.2009_P+X03.2009_P+X04.2009_P+X05.2009_P+X06.2009_P+X07.2009_P+X08.2009_P+X09.2009_P+X10.2009_P+X11.2009_P+X12.2009_P+
X01.2010_P+X02.2010_P+X03.2010_P+X04.2010_P+X05.2010_P+X06.2010_P+X07.2010_P+X08.2010_P+X09.2010_P+X10.2010_P+X11.2010_P+X12.2010_P+
X01.2011_P+X02.2011_P+X03.2011_P+X04.2011_P+X05.2011_P+X06.2011_P+X07.2011_P+X08.2011_P+X09.2011_P+X10.2011_P+X11.2011_P+X12.2011_P+
X01.2012_P+X02.2012_P+X03.2012_P+X04.2012_P+X05.2012_P+X06.2012_P+X07.2012_P+X08.2012_P+X09.2012_P+X10.2012_P+X11.2012_P+X12.2012_P+
X01.2013_P+X02.2013_P+X03.2013_P+X04.2013_P+X05.2013_P+X06.2013_P+X07.2013_P+X08.2013_P+X09.2013_P+X10.2013_P+X11.2013_P+X12.2013_P+
X01.2014_P+X02.2014_P+X03.2014_P+X04.2014_P+X05.2014_P+X06.2014_P+X07.2014_P+X08.2014_P+X09.2014_P+X10.2014_P+X11.2014_P+X12.2014_P+
X01.2015_P+X02.2015_P+X03.2015_P+X04.2015_P+X05.2015_P+X06.2015_P+X07.2015_P+X08.2015_P+X09.2015_P+X10.2015_P+X11.2015_P+X12.2015_P ~ MUN_RESID, data = months_total_f052, auto.key = list(space = 'left'), horiz = FALSE, ylab="percent_dead", scales=list(x=list(rot=90)))
This might be what you are after? I think with a ton of data "small multiples" is a decent approach. Without your full data set I don't think you'll get the picture but worth a try:
library(tidyverse)
dat <- tribble(
~"MUN_RESID", ~"X08.2005_P", ~"X09.2005_P", ~"X10.2005_P", ~"X11.2005_P", ~"X12.2005_P",
120043, 0.00000000, 0.22382438, 0.02797805, 0.00000000, 0.00000000,
150775, 0.00000000, 0.02475672, 0.00000000, 0.00000000, 0.00000000,
170025, 0.00000000, 0.00000000, 0.00000000, 0.04305349, 0.00000000,
170382, 0.04510756, 0.00000000, 0.00000000, 0.00000000, 0.00000000,
171180, 0.00000000, 0.04180602, 0.00000000, 0.00000000, 0.00000000,
171525, 0.04113143, 0.00000000, 0.00000000, 0.00000000, 0.00000000,
172025, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.03480216,
)
# We need to convert the data long ways
long_data <- dat %>%
gather(date, value, - MUN_RESID) %>%
separate(col = date, into = c("month", "year"), sep = "\\.") %>%
mutate(month = str_extract(month, "\\d+") %>% parse_double()) %>%
mutate(year = str_extract(year, "\\d+") %>% parse_double()) %>%
mutate(my_month = factor(month))
# Now we can graph
long_data %>%
ggplot(aes(MUN_RESID, value)) +
facet_wrap(~year)+
geom_col(aes(fill = my_month), position = "dodge", stat="identity")+
coord_flip()+
theme_minimal()