Related
I am trying to check the model fit of a glmm with an inverse gaussian distribution, using the DHARMa package.
library(lme4)
library(DHARMa)
glmm2<-glmer(time ~ noise + md+ (1|id),
data=data,
family=inverse.gaussian(link="identity"))
sim<-simulateResiduals(glmm2)
Yet, I get this error message:
Error in sfun(object, nsim = 1, ftd = rep_len(musim, n * nsim), wts = weights) :
could not find function "sfun"
However, the code runs fine with other distributions.
This may be the same issue as one posted here: https://github.com/lme4/lme4/issues/284
After reading this thread, Ben Bolker recently fixed an lme4 issue with the inverse.gaussian distribution, yet updating the "lme4" package via install.packages() doesn't solve the issue.
Could this be because the committed fix is not yet on CRAN (only GitHub), or is this be a separate issue entirely?
Here is some data to make a reproducible example (although I don't think it is a problem with this specific data):
data<-structure(list(time = c(41.13741586, 9.782034165, 28.43048335,
3.207626451, 3.28737433, 12.17147616, 6.846317411, 7.060553219,
9.551505159, 1.946177066, 7.792069828, 3.391127888, 5.691814361,
6.093369116, 8.293302802, 7.56783162, 3.780120891, 9.783027043,
4.24972651, 2.876613826, 3.601603686, 29.13667211, 3.424758707,
3.675592368, 13.0437798, 7.547469641, 8.842781853, 8.300757096,
2.979181386, 3.419450337, 16.45199251, 3.127217308, 8.747828301,
3.428571841, 3.70943289, 11.04721516, 2.903853931, 3.440767391,
2.785837122, 3.269951103, 2.410238878, 3.89081111, 4.619280336,
2.992322509, 5.783528547, 34.00289472, 24.44992761, 23.23027649,
9.014569882, 5.894704299, 3.055185939, 2.218424498, 6.382338632,
2.755323799, 7.076236215, 3.262103618, 3.922126491, 23.61442673,
18.48894273, 4.800960669, 2.48269627, 3.146589815, 6.439999987,
7.668507118, 6.419151537, 3.542393771, 3.043635607, 2.884369079,
2.491696809, 27.55352679, 1.897232137, 2.588586002, 4.559529659,
5.193832311, 6.66462235, 7.575937154, 4.267289699, 3.077610554,
2.539769396, 11.04715723, 3.938594629, 2.990035169, 11.62055069,
6.286390667, 3.066117908, 3.036437669, 14.09709544, 2.247126905,
3.437216412, 2.22807457, 4.380971792, 2.947254937, 8.787878448,
3.107896369, 11.28890645, 3.550776501, 7.142133246, 2.362423895,
4.305386462, 9.045445478, 3.267399008, 4.677552175, 4.718496658,
3.600337195, 10.44240212, 10.15304052, 9.183458325, 5.928181431,
25.03263407, 3.076395187, 24.38716969, 2.239600859, 2.172207797,
8.76376451, 3.183504181, 2.35993369, 8.295343346, 3.418330144,
3.620356333, 10.54711979, 14.21928106, 10.37029106, 6.031589426,
3.981959804, 5.342755734, 7.904376564, 5.718102126, 3.410403438,
9.692149582, 3.13309998, 19.3245972, 4.335996613, 4.841560445,
12.32188778, 45.52278629, 2.752979722, 12.47383626, 2.134412308,
14.44585039, 16.10740155, 5.788136583, 4.511246787, 16.7312537,
3.73230319, 4.897898902, 6.028128975, 52.0381691, 4.068210128,
6.398227764, 6.118767994, 8.548906531, 3.390646287, 2.490769614,
4.111526974, 4.832608955, 8.289365702, 50.2465904, 2.646893295,
9.719880568, 4.641543, 4.771943998, 3.706358115, 4.166786292,
4.179320836, 19.52129995, 3.174416789, 6.275250101, 3.749363137,
5.181954223, 5.163764939, 6.324603377, 6.036336947, 2.908604885,
4.982428475, 6.323173522, 3.64608021, 11.80631532, 3.387963324,
14.29897945, 3.482688516, 9.645221336, 62.40574289, 3.706740696,
20.86882567, 3.251831744, 4.462031664, 15.50260099, 6.022609352,
9.416738158, 8.162124214, 16.92103384, 4.452837389, 33.60315353,
2.323210606, 4.633791727, 10.51593419, 9.167247429, 3.827658235,
3.828607871, 3.829411261, 20.42109578, 3.272191767, 13.08373561,
9.823979107, 2.954488994, 5.89699479, 17.77766321, 14.2193287,
4.84425791, 3.046470241, 4.376652312, 4.075512895, 4.447326956,
3.828587987, 3.301959055, 3.266122424, 5.958960708, 9.809333414,
3.370849736, 3.434066392, 8.531563826, 2.380370139, 11.32306372,
30.78310772, 3.105894163, 2.326072315, 5.804816817, 45.1877515,
5.479398096, 3.452887784, 8.392957238, 3.594501224, 4.455098706,
5.13784923, 4.560898241, 17.59137752, 5.411802079, 6.662678284,
6.724703395, 3.416384684, 3.478441765, 18.28886191, 16.76116317,
16.98330296, 12.38336171, 39.52376287, 7.454258623, 4.174623206,
7.837446903, 4.988091336, 4.781385826, 3.463154542, 3.464226543,
25.43735658, 3.067537685, 4.258702803, 7.340216019, 49.14047038,
2.442459709, 9.447392998, 3.197442493, 10.22828166, 4.628425949,
9.199019126, 3.482760092, 4.764069625, 4.705087528, 8.058345229,
3.430036022, 66.06439786, 10.77330705, 3.786447776, 10.80383314,
3.757634691, 17.21945979, 9.280765277, 5.620796286, 3.512069001,
4.904388737, 6.275277039, 13.81807132, 4.628234066, 2.979297419,
3.290358325, 10.74032344, 13.65048463, 4.281098604, 8.967766237,
4.149626936, 2.59, 12.85102282, 23.00134089, 4.814198164, 4.564720885,
7.195367624, 4.696707842, 9.477280147, 6.887927244, 19.009986,
4.660588773, 13.41105483, 4.041755049, 3.173568488, 4.533755494,
21.314069, 6.814173148, 7.955226733, 3.486861445, 28.51746697,
12.26761549, 47.51824882, 7.208537936, 5.800505255, 3.860646939,
43.02148852, 18.30155857, 8.401628238, 5.581668235, 40.0252368,
41.82807892, 15.43939019, 43.93014117, 8.546396018, 18.18405266,
11.05878955, 6.290103866, 3.290309576, 11.79316794, 12.91487095,
55.84556727, 4.41720961, 7.462505685, 11.52409499, 9.08413754,
3.654474629, 3.774640913, 11.77560963, 5.246143327, 4.528003446,
3.720297554, 26.86158631, 3.121956906, 3.814112187, 3.915468981,
3.855898118, 6.066957123, 5.818204851, 15.38006946, 4.82077121,
5.601840547, 8.673335565, 94.57364072, 11.72416331, 3.857151745,
12.63774199, 3.077864042, 22.91825688, 4.779887153, 3.02290964,
65.38458973, 14.61544757, 4.589837739, 30.27093406, 8.562364255,
9.152543612, 7.5945589, 13.78637596, 20.53718869, 15.09996703,
10.51215369, 22.19312527, 4.103858301, 72.50651558, 5.917881591,
3.918046252, 25.73809912, 10.11106179, 4.611947838, 3.812338842,
66.11236733, 3.083073479, 3.923163416, 4.274799646, 5.147559259,
8.04819077, 7.429203003, 77.1197558, 4.241240055, 18.20449757,
12.15671963, 12.63195774, 73.33069624, 31.72095844, 6.66150562,
23.73213392, 4.694739577, 3.798945831, 15.67155682, 10.48168672,
5.333182065, 4.850010439, 7.652005471, 4.532210133, 4.402485395,
35.35353175, 3.903941738, 3.184677454, 18.55515345, 2.687618202,
2.818215173, 10.03921751, 18.5694306, 15.06234012, 7.16657676,
9.080463855, 22.45095501, 7.831502889, 4.232363182, 66.17311789,
7.304880603, 6.61580356, 6.178855732, 5.060957087, 8.331560974,
3.81257565, 4.744033321, 8.284062198, 4.095163125, 50.18527387,
4.467955136, 7.55798715, 93.1895922, 9.163073489, 4.843419754,
3.495555564, 21.29713932, 6.607945438, 9.949066825, 5.671821957,
4.052717444, 4.392775373, 6.805400321, 4.67567415, 3.61639655,
4.266905617, 6.179724612, 5.499797952, 9.431915978, 61.31221724,
88.713231, 47.87339455, 4.184470597, 5.814770604, 7.722124227,
26.91274215, 22.26364589, 10.32376603, 38.02472068, 6.755221955,
6.655862961, 12.47736033, 3.832455267, 5.794588666, 2.29488901,
4.825032889, 5.707439328, 8.237935874, 3.398480834, 5.020340238,
16.54083878, 3.872542885, 88.54425795, 5.625607924, 32.84691682,
3.567019038, 17.90767527, 4.201325706, 7.412715166, 5.096011771,
98.45740835, 35.65809944, 6.7282369, 5.479067069, 3.009588285,
21.26465113, 6.047096921, 24.7085676, 22.26897628, 52.27063039,
5.302204077, 17.0241899, 5.52564186, 6.185931004, 10.56671436,
3.498058554, 5.589325271, 12.77965649, 3.449802552, 6.220177507,
3.650345073, 6.560421815, 65.29056106, 12.65290021, 14.25446065,
2.534825382, 3.594919078, 6.195722329, 68.28617492, 21.81716823,
7.727936448, 73.08995666, 7.790689, 5.263312258, 22.09589367,
9.419771743, 9.770269026, 7.020954402, 23.4026281, 8.625718029,
18.406882, 4.657678486, 11.65835826, 10.45855645, 6.720511821,
9.492626932, 20.41736393, 5.287491136, 17.4677231, 47.21784241,
4.230403918, 6.071208513, 44.32271069, 13.41734888, 47.57801238,
8.772598635, 9.205175901, 8.55700878, 4.897450519, 4.737495931,
4.338049612, 6.215468258, 4.165600023, 5.036888453, 9.569007641,
6.071899787, 7.542304652, 4.732480187, 3.442827096, 41.35375961,
4.353765853, 3.753951093, 4.664248723, 60.85668314, 80.35729941,
12.89760767, 3.989420233, 35.96090859, 6.392164591, 4.392808509,
11.64349675, 15.16356068, 26.66641769, 10.30722888, 4.189055807,
26.46911323, 19.37062122, 2.591032044, 27.77127424, 12.09154189,
62.07235295, 5.432750085, 6.406463399, 47.77777956, 7.039493391,
4.221247722, 68.8818966, 24.38479969, 8.887155651, 12.18805931,
4.821592099, 15.80203651, 8.702592898, 59.69323291, 6.059270163,
11.45979501, 39.40068331, 3.901232778, 4.811936493, 5.465225016,
8.156093384, 3.497747496, 6.628207287, 13.90997849, 10.91123037,
7.823507377, 17.41400512, 3.335581008, 8.165933257, 8.858253615,
3.11079724, 11.54130872, 8.642978559, 9.713731749, 4.457465386,
20.51801412, 7.558962511, 19.09083352, 3.111885984, 4.773125492,
3.936568118, 5.317176674, 23.43778227, 15.63826616, 36.44002133,
13.38015732, 5.292505485, 4.783865063, 22.66444017, 20.60565127,
11.78703337, 10.74863376, 22.88895906, 16.73011321, 4.040348858,
4.304943155, 5.026492863, 10.01713706, 5.648188872, 7.178448492,
3.460327443, 15.40073695, 2.682902487, 5.774015487, 67.56871224,
18.67961631, 5.100519708, 8.061332641, 5.132089571, 32.47386136,
9.414060145, 7.254471895, 10.75556407, 5.658317047, 11.56855848,
10.92050226, 7.863734311, 44.48384677, 7.864493752, 16.73642175,
35.13153666, 2.83164151, 89.49256856, 9.29474009, 3.344889429,
23.59843601, 15.66216937, 3.34173857, 5.943488483, 51.65482739,
55.39614187, 9.007741113, 5.787799271, 9.848206998, 7.538856381,
5.3796996, 9.950124408, 9.330343418, 5.311483191, 6.261800614,
11.45253276, 11.48741207, 18.04993558, 87.72143563, 23.92329284,
5.715208533, 3.116109407, 3.526837879, 7.089243781, 3.839410349,
3.380133647, 35.83050327, 45.93174123, 6.824078926, 4.974603407,
64.13461403, 13.5354574, 4.186924017, 7.010327493, 60.94089111,
7.953126298, 7.763630404, 4.355139132, 8.766348864, 8.297972846,
5.489028514, 16.14967745, 20.55160891, 9.801691177, 24.05331142,
3.054056576, 6.356113769, 4.526387275, 41.05646944, 87.15748558,
3.087562276, 11.55760686, 41.55854476, 6.389576519, 41.56061368,
8.631088213, 3.561678389, 3.412607997, 5.433127705, 13.46547347,
8.016249869, 11.18752614, 16.80909843, 7.509632253, 6.200475612,
8.00121421, 4.92138598, 7.852715585, 17.13290285, 5.853321497,
2.704434081, 83.67600754, 21.60982366, 72.68196408, 4.86197169,
6.143998414, 5.984085597, 65.7869803, 17.43792585, 14.28896726,
5.339398457, 7.309532293, 5.8, 20.68070572, 4.440736792, 13.19366278,
62.89981678, 4.4, 31.40239036, 12.29444914, 7.385797172, 10.19820787,
8.893010935, 7.273767797, 30.61441959, 10.995188, 80.21558756,
67.91582164, 4.216706087, 9.11802591, 13.41809671, 38.11920761,
26.81937129, 8.399840607, 31.41988565, 5.970228522, 14.62953905,
6.906308231, 46.42810685, 4.259323889, 7.90956253, 12.69999747,
9.941220655, 5.611597938, 4.101697356, 4.97251454, 3.29426027,
5.674547381, 7.135133419, 4.32571262, 11.23584732, 5.356806181,
21.1381246, 5.640204077, 50.64098656, 21.74196711, 7.114049809,
69.14405789, 11.08407918, 9.614960631, 6.305296022, 9.425762636,
3.586616832, 3.987438688, 4.707836204, 13.98798518, 49.25125373,
12.6221062, 5.775052381, 7.006755171, 43.65712799, 14.24896706,
13.09035569, 5.603557141, 7.363880162, 4.604196486, 6.604373673,
4.825110605, 10.38589501, 17.66593416, 8.006941271, 4.158453861,
30.85879709, 13.21918021, 10.67157215, 6.241612269, 98.17192465,
32.67287969, 4.983331185, 20.29372069, 4.804043711, 4.266221754,
7.117825467, 13.19915511, 5.989386148, 3.930709804, 4.522719284,
3.872789982, 5.934531644, 48.88519892, 4.995590229, 10.71702774,
58.18713996, 5.408302428, 7.210063546, 34.49123805, 7.791664114,
4.784022296, 13.19515942, 5.565235072, 18.58556714, 35.69660968,
6.817019169, 49.69835067, 5.162957511, 9.423694931, 16.73454058,
37.50499864, 3.545501923, 4.086844008, 5.158503892, 11.30946687,
6.339981148, 5.402200808, 60.7157093, 8.996041752, 4.716424861,
4.746533209, 32.03878257, 5.183617664, 13.52553971, 25.8217186,
6.283448511, 5.283619437, 4.663705606, 4.784524026, 37.72518574,
7.475938419, 4.256979349, 6.747055688, 5.389175626, 5.789724431,
3.890042036, 9.230814747, 5.830958808, 10.17128062, 97.2313699,
4.891389037, 4.032935801, 6.073353203, 7.983586247, 13.92732222,
4.387520417, 10.6082623, 57.7389435, 10.9914034, 6.372993563,
5.864494002, 37.24617264, 7.746659158, 4.558902538, 7.149688515,
5.721092216, 3.031219963, 6.881457428, 5.401788271, 18.4342511,
5.034322669, 5.823274353, 9.895358183, 5.606547324, 12.17744259,
8.990127566, 7.144633101, 5.840023387, 14.22145227, 3.661540144,
31.78595354, 60.78602018, 9.568657786, 6.589606217, 11.5004296,
11.26096657, 3.7317475, 25.79324716, 6.545466266, 37.7943937,
7.044451557, 6.626310111, 6.69666011, 14.07726794, 5.477346607,
12.88805136, 53.79825342, 42.80146828, 6.402334652, 5.99360942,
33.80524434, 6.40734361, 20.80743047, 8.030528537, 51.41054388,
3.750730015, 8.742226584, 5.312386607, 8.943284188, 4.753595783,
51.41416859, 6.345055058, 4.156655336, 7.06692512, 5.198644681,
10.73224033, 10.66319026, 3.673375589, 6.633472681, 30.22377284,
10.92891361, 37.02492114, 3.667219484, 54.02734635, 12.10764859,
10.04801493, 6.57970909, 41.83188115, 5.08416902, 4.295467738,
5.370520688, 62.8468498, 71.04833317, 7.568852093, 7.409029886,
11.97942712, 5.160546297, 34.05225643, 84.75282622, 6.063497811,
4.663622269, 64.75434338, 5.275457924, 4.267158793, 19.85760569,
38.8584257, 5.450269513, 19.66255491, 90.3618477, 15.36214503,
7.193836378, 45.46389467, 12.66542026, 5.485897332, 9.179153293,
5.149186649, 6.729612253, 10.83999684, 8.430694187, 7.311419643,
17.17267499, 21.79455081, 5.344759649, 4.295641456, 9.466075813,
20.16667645, 13.34790152, 10.37801212, 62.37881405, 44.02705672,
6.281168569, 7.602319351, 11.60387192, 13.1849234, 5.605190238,
5.855195352, 21.38760878, 3.88769096, 7.078750029), noise = c(2L,
3L, 5L, 4L, 5L, 5L, 4L, 5L, 5L, 2L, 5L, 4L, 3L, 2L, 4L, 5L, 5L,
5L, 2L, 3L, 4L, 3L, 4L, 4L, 5L, 5L, 5L, 5L, 2L, 4L, 2L, 2L, 4L,
5L, 4L, 5L, 5L, 5L, 2L, 2L, 4L, 4L, 2L, 2L, 5L, 4L, 2L, 4L, 5L,
4L, 5L, 2L, 5L, 2L, 1L, 2L, 5L, 4L, 4L, 5L, 2L, 5L, 1L, 4L, 5L,
4L, 5L, 2L, 3L, 4L, 3L, 2L, 2L, 5L, 4L, 4L, 2L, 4L, 2L, 5L, 3L,
3L, 5L, 5L, 3L, 3L, 4L, 3L, 4L, 3L, 4L, 2L, 1L, 4L, 5L, 5L, 5L,
2L, 5L, 3L, 2L, 2L, 2L, 2L, 4L, 5L, 4L, 5L, 5L, 4L, 4L, 2L, 2L,
4L, 4L, 3L, 4L, 3L, 2L, 3L, 4L, 4L, 2L, 4L, 4L, 4L, 3L, 2L, 2L,
4L, 2L, 4L, 2L, 4L, 5L, 2L, 4L, 2L, 2L, 4L, 5L, 3L, 2L, 2L, 2L,
4L, 5L, 2L, 4L, 2L, 5L, 2L, 4L, 2L, 2L, 5L, 2L, 2L, 4L, 2L, 4L,
2L, 2L, 5L, 3L, 2L, 3L, 2L, 4L, 1L, 4L, 1L, 3L, 2L, 3L, 3L, 4L,
3L, 5L, 3L, 3L, 5L, 2L, 2L, 3L, 2L, 2L, 4L, 5L, 5L, 1L, 5L, 4L,
3L, 2L, 2L, 2L, 3L, 2L, 3L, 2L, 2L, 4L, 1L, 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, 4L,
1L, 1L, 3L, 3L), .Label = c("Anshin", "Cartman", "Chiarah", "Mucki"
), class = "factor"), md = c(8, 8, 2, 2, 2, 2, 2, 5.66, 2, 16,
1, 4, 1, 8, 1, 5.66, 2.83, 8, 16, 4, 8, 1, 16, 4, 2, 2.83, 1,
1, 8, 2.83, 2, 16, 8, 8, 5.66, 4, 4, 4, 2, 5.66, 16, 1, 5.66,
5.66, 16, 2.83, 5.66, 8, 2, 1, 5.66, 16, 2, 8, 8, 5.66, 5.66,
4, 8, 2, 16, 16, 1, 2, 8, 8, 2.83, 4, 8, 2.83, 16, 16, 5.66,
16, 8, 5.66, 8, 1, 5.66, 5.66, 8, 2, 1, 8, 16, 2, 16, 16, 8,
2.83, 4, 5.66, 4, 2.83, 1, 16, 2.83, 1, 8, 16, 16, 2, 16, 8,
16, 16, 2, 8, 16, 1, 1, 16, 8, 5.66, 2, 8, 2, 5.66, 2.83, 1,
5.66, 2, 5.66, 4, 4, 2, 2, 2.83, 2, 4, 4, 1, 8, 5.66, 2, 4, 4,
8, 2.83, 2, 4, 1, 4, 5.66, 1, 16, 1, 5.66, 2.83, 2.83, 4, 8,
8, 16, 4, 4, 2, 8, 1, 8, 2.83, 5.66, 2.83, 2.83, 1, 2, 5.66,
4, 5.66, 8, 1, 16, 5.66, 1, 2, 4, 2, 5.66, 16, 1, 5.66, 5.66,
2.83, 2.83, 2, 2, 2.83, 2.83, 2, 8, 4, 8, 2, 16, 2, 5.66, 16,
4, 2.83, 4, 5.66, 1, 2, 1, 4, 4, 8, 2, 1, 4, 2.83, 2, 5.66, 2,
2, 2.83, 8, 1, 4, 8, 4, 8, 8, 5.66, 4, 16, 2, 2.83, 1, 16, 2.83,
8, 1, 8, 4, 4, 1, 8, 2, 5.66, 8, 8, 4, 8, 1, 4, 2.83, 16, 16,
2, 1, 2, 16, 2, 16, 16, 8, 2.83, 16, 1, 8, 2, 1, 1, 1, 4, 4,
2, 16, 16, 2.83, 5.66, 4, 2.83, 8, 2, 5.66, 2, 1, 2.83, 4, 1,
4, 8, 8, 2, 1, 8, 2.83, 8, 2.83, 5.66, 4, 2.83, 5.66, 2.83, 1,
2, 8, 1, 2.83, 8, 2.83, 4, 5.66, 2.83, 2, 16, 2.83, 8, 4, 16,
4, 2.83, 16, 1, 2, 2.83, 16, 2, 16, 2.83, 16, 5.66, 4, 2.83,
1, 2, 8, 5.66, 2, 8, 16, 1, 2.83, 5.66, 1, 2, 4, 1, 2, 2, 16,
4, 2, 8, 1, 4, 5.66, 2, 4, 5.66, 1, 2, 2.83, 5.66, 8, 16, 2.83,
16, 2, 1, 4, 4, 2.83, 4, 4, 2, 16, 8, 8, 4, 8, 2, 8, 5.66, 16,
1, 1, 1, 4, 2.83, 2.83, 2, 2.83, 8, 1, 4, 16, 5.66, 4, 8, 1,
8, 4, 4, 16, 2.83, 1, 1, 8, 16, 5.66, 5.66, 16, 16, 2, 2, 5.66,
16, 2.83, 4, 5.66, 1, 8, 4, 2.83, 2, 2.83, 4, 2, 8, 1, 5.66,
1, 8, 1, 1, 16, 16, 4, 16, 4, 2, 2.83, 4, 4, 5.66, 5.66, 16,
4, 2, 8, 8, 8, 1, 8, 5.66, 5.66, 16, 16, 1, 2, 2, 16, 1, 4, 1,
1, 5.66, 5.66, 2, 4, 16, 1, 1, 4, 16, 2, 1, 2.83, 1, 2, 4, 4,
2, 2, 16, 2, 16, 1, 4, 2.83, 5.66, 8, 16, 2, 1, 16, 2, 2, 4,
5.66, 2, 1, 1, 8, 16, 2, 8, 4, 2, 8, 1, 2, 2, 2.83, 2.83, 8,
2, 2.83, 2.83, 2, 2.83, 1, 5.66, 2.83, 5.66, 8, 8, 8, 1, 1, 16,
1, 2.83, 5.66, 8, 16, 5.66, 2, 5.66, 5.66, 2, 1, 5.66, 8, 2.83,
16, 2.83, 1, 16, 16, 4, 4, 2.83, 5.66, 16, 16, 2.83, 16, 8, 4,
2.83, 16, 8, 8, 5.66, 2, 2.83, 5.66, 8, 1, 5.66, 8, 2.83, 5.66,
8, 2, 4, 5.66, 8, 16, 1, 16, 4, 2, 16, 2.83, 2.83, 4, 5.66, 4,
1, 16, 2, 5.66, 1, 2.83, 5.66, 2, 2, 5.66, 8, 5.66, 1, 1, 2,
4, 5.66, 2, 4, 1, 5.66, 16, 1, 8, 2.83, 4, 16, 2, 16, 16, 8,
1, 4, 4, 5.66, 1, 4, 1, 4, 1, 5.66, 1, 5.66, 4, 1, 1, 16, 5.66,
1, 1, 5.66, 4, 8, 4, 2, 2, 2, 1, 4, 5.66, 2, 5.66, 2.83, 4, 5.66,
5.66, 16, 4, 5.66, 4, 8, 2.83, 16, 1, 5.66, 8, 5.66, 16, 4, 16,
2, 2.83, 2, 1, 2.83, 1, 5.66, 2.83, 2, 1, 2.83, 4, 16, 2, 16,
2, 2.83, 1, 16, 4, 2.83, 5.66, 2.83, 1, 5.66, 8, 4, 8, 2, 2,
1, 2, 4, 5.66, 16, 2.83, 16, 16, 2, 5.66, 2, 8, 16, 2, 8, 16,
2.83, 16, 2, 8, 1, 5.66, 1, 5.66, 5.66, 16, 1, 16, 16, 1, 2,
5.66, 16, 1, 2, 5.66, 2.83, 1, 16, 5.66, 1, 1, 2.83, 1, 4, 4,
2, 1, 2, 2.83, 4, 5.66, 2.83, 2, 2.83, 1, 1, 1, 1, 2, 16, 8,
4, 4, 16, 5.66, 5.66, 1, 4, 5.66, 2.83, 5.66, 8, 1, 1, 2, 1,
2.83, 1, 2, 8, 16, 5.66, 8, 4, 5.66, 4, 1, 1, 2, 16, 8, 4, 4,
2.83, 4, 8, 16, 16, 4, 5.66, 5.66, 4, 8, 2, 4, 5.66, 1, 2, 5.66,
8, 16, 2.83, 2, 1, 5.66, 1, 2.83, 5.66, 2.83, 16, 16, 2, 2, 16,
16, 1, 1, 5.66, 2.83, 1, 16, 2, 1, 2, 1, 4, 16, 5.66, 5.66, 1,
16, 5.66, 2, 16, 1, 16, 1, 1, 8, 16, 5.66, 5.66, 5.66, 16, 16,
5.66, 5.66, 5.66, 4, 1, 8, 4, 5.66, 1, 8, 2, 8, 2, 5.66, 4, 16,
5.66, 5.66, 2.83, 5.66, 8, 8, 1, 16, 16, 2, 4, 8, 5.66, 2, 5.66,
16, 2, 4, 16, 8, 1, 2.83, 1, 1, 2.83, 1, 8, 2, 16, 1, 4, 8, 5.66,
1, 8, 16, 2, 4, 16, 5.66, 2.83, 4, 8, 4, 4, 16, 16, 2.83, 8,
5.66, 5.66, 16, 16, 16, 1, 2.83, 4, 2, 2.83, 4, 1, 2, 16, 2.83,
16, 4, 8, 2, 5.66, 2, 2.83, 4, 2, 2.83, 2, 16, 2.83, 5.66, 4,
1, 1, 2.83, 2.83, 1, 2.83, 8, 5.66, 4, 4, 5.66, 1, 8, 16, 5.66,
5.66, 2.83, 2, 16, 2.83, 1, 5.66, 4, 4, 2.83, 2, 4, 16, 2.83,
2.83, 16, 8, 2.83, 2.83, 8, 4, 5.66, 8, 2.83, 4, 4, 4, 1, 2.83,
8, 8, 8, 8, 8, 4, 2, 8, 8, 5.66, 16, 2.83)), class = "data.frame", row.names = c(NA,
-1000L))
(see https://stats.stackexchange.com/questions/254361/modeling-reaction-time-with-glmer for explanation on why this particular distribution for response time data. Original paper here: https://doi.org/10.3389/fpsyg.2015.01171)
To see whether a linear trend exists between age and quartiles of some variable, I fitted a linear model using lm. Plots of the residuals against fitted values as well as residuals against the quartiles indicate heterogeneity of variance.
This image was created through:
m1 <- lm(age ~ quartile, data = DF) #DF = dataframe
op <- par(mfrow = c(1,3))
plot(resid(m1) ~ fitted(m1)) #Homogeneity of variances: graphical
plot(resid(m1) ~ DF$quartile)
qqnorm(resid(m1));qqline(resid(m1))
par(op)
Within the GLS framework, I would like to have the residual variance to depend on the quartiles using one of the classes from the varFunc from the nlme package. I tried multiple functions, though without success.
The sample data below roughly yield the same pattern:
reconstruct <- structure(list(quartile = structure(c(2L, 1L, 4L, 3L, 1L, 1L,
3L, 4L, 3L, 2L, 2L, 3L, 3L, 1L, 2L, 4L, 2L, 2L, 2L, 1L, 1L, 3L,
1L, 1L, 1L, 3L, 3L, 1L, 4L, 3L, 3L, 3L, 2L, 4L, 1L, 1L, 3L, 1L,
3L, 2L, 2L, 4L, 3L, 4L, 1L, 4L, 1L, 4L, 3L, 1L, 1L, 2L, 4L, 2L,
2L, 2L, 1L, 1L, 4L, 1L, 4L, 4L, 3L, 3L, 4L, 4L, 1L, 1L, 2L, 1L,
4L, 3L, 4L, 2L, 3L, 3L, 3L, 1L, 1L, 4L, 1L, 2L, 1L, 2L, 1L, 1L,
2L, 4L, 1L, 3L, 4L, 2L, 4L, 1L, 4L, 4L, 1L, 3L, 4L, 2L, 2L, 1L,
1L, 4L, 2L, 4L, 3L, 4L, 4L, 4L, 3L, 3L, 3L, 3L, 2L, 2L, 4L, 2L,
4L, 1L, 4L, 3L, 4L, 1L, 2L, 1L, 4L, 2L, 1L, 3L, 1L, 4L, 1L, 4L,
4L, 4L, 1L, 1L, 4L, 2L, 4L, 3L, 2L, 2L, 1L, 3L, 1L, 4L, 2L, 3L,
4L, 3L, 4L, 1L, 1L, 2L, 2L, 4L, 1L, 2L, 4L, 2L, 1L, 2L, 1L, 1L,
4L, 3L, 2L, 3L, 2L, 4L, 3L, 4L, 1L, 4L, 1L, 3L, 4L, 4L, 4L, 1L,
4L, 3L, 2L, 4L, 3L, 3L, 2L, 1L, 1L, 4L, 1L, 4L, 2L, 2L, 2L, 4L,
2L, 3L), .Label = c("1", "2", "3", "4"), class = c("ordered",
"factor")), age = c(40.45, 33.49, 41.02, 53.06, 63.46, 47.17,
39.45, 60.71, 67.13, 53.12, 62.78, 70.39, 56.14, 50.55, 35.64,
38.5, 68.53, 53.69, 50.84, 38.66, 35.31, 57.03, 37.84, 35.82,
50.68, 56.44, 65.36, 58.64, 55.98, 56.13, 42.09, 54.91, 35.16,
63.68, 44.5, 51.79, 69.56, 59.11, 55.39, 43.87, 58.12, 65.59,
52.58, 60.17, 48.57, 52.09, 40.04, 35.61, 77.14, 43.82, 48.98,
36.26, 44.63, 62.13, 69.59, 41.22, 47.85, 53.5, 42.08, 49.08,
75.49, 52.39, 41.21, 58.25, 74.37, 64.28, 34.01, 42.99, 34.05,
60.99, 68.82, 41.3, 71.07, 55.21, 52.01, 37.76, 64.54, 57.43,
45.78, 62.9, 67.73, 49.25, 69.68, 51.85, 37.32, 47.37, 53.41,
68.55, 35.31, 63.59, 69.04, 48.03, 50.74, 42.93, 79.23, 72.22,
35.42, 43.26, 45.81, 37.92, 39.26, 60.97, 47.36, 50.19, 43.52,
41.82, 40.42, 54.87, 55.32, 75.74, 69.54, 56.44, 59.85, 50.02,
49.23, 48.38, 34.07, 38.57, 46.57, 35.29, 42.04, 63.35, 34.68,
50.34, 72.5, 40.27, 58.41, 37.79, 34.62, 75.47, 38.91, 46.21,
49.72, 40.55, 66.98, 59.07, 55.8, 38.86, 47.76, 59.16, 74.79,
57.87, 54.82, 43.58, 66.15, 34.55, 50.12, 67.68, 61.1, 40.29,
54.1, 69.8, 60.68, 36.7, 38.31, 46.15, 34.68, 41.92, 38.97, 50.67,
68.53, 40.06, 46.5, 44.38, 47.6, 37.95, 78.39, 54.73, 79.07,
40.05, 48.67, 58.71, 73.07, 75.65, 43.07, 48.25, 44.03, 51.37,
62.16, 54.78, 66.27, 50.25, 60.56, 32.77, 68.41, 37.74, 38.46,
46.33, 41.59, 64.52, 53.66, 71.04, 64.55, 53.25, 40.58, 52.33,
39.64, 52.76, 43.52, 48.45)), row.names = c(1:200), class = "data.frame")
To obtain the image:
m2 <- lm(age ~ quartile, data = reconstruct)
op <- par(mfrow = c(1,3))
plot(resid(m2) ~ fitted(m2))
plot(resid(m2) ~ reconstruct$quartile)
qqnorm(resid(m2));qqline(resid(m2))
par(op)
Any suggestions?
I am plotting grouped barplots with error bars, but my error bars are very long as in this image
[![https://i.stack.imgur.com/VUByO.png][1]][1].
I would like shorter error bars as in this image
[![https://i.stack.imgur.com/JhaUJ.png][2]][2]
The code used
per$Leaf_Location <- factor(per$Leaf_Location, levels = unique(per$Leaf_Location))
per$Time <- factor(per$Time, levels = unique(per$Time))
ggplot(per, aes(x=Leaf_Location, y=Damage, fill=as.factor(Time))) +
stat_summary(fun.y=mean,
geom="bar",position=position_dodge(),colour="black",width=.7,size=.7) +
stat_summary(fun.ymin=min,fun.ymax=max,geom="errorbar",
color="black",position=position_dodge(.7), width=.2) +
stat_summary(geom = 'text', fun.y = max, position = position_dodge(.7),
label = c("a","b","c","d","d","a","b","c","d","d","a","b","c","d","d"), vjust = -0.5) +
scale_fill_manual("Legend", values = c("grey36","grey46","grey56","grey76","grey86","grey96")) +
xlab("Leaf Location") +
ylab("Damage ") +
theme_bw()
data:
per =
structure(list(Site = structure(c(2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 3L,
3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L,
3L, 3L, 3L, 3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"100_days"), class = "factor"),
Damage = c(25.25, 26.07, 24.43, 20.73, 17.8, 6.9, 45.05,
33.47, 24.43, 51.67, 41.72, 34.17, 81.67, 73.33, 55.83, 34.28,
26.08, 13.28, 26.27, 14.1, 6.93, 37.55, 29.33, 23.62, 49.17,
38.45, 31.38, 70.83, 60.83, 44.2, 31.03, 25.2, 14.97, 14.38,
6.5, 4.33, 52.2, 39.17, 30.97, 75, 62.5, 38.33, 87.5, 62.5,
57.5, 45.02, 31.02, 26.07, 46.72, 34.32, 21.5, 50.83, 34.23,
25.25, 45.83, 33.47, 27.7, 67.67, 57.5, 52.67, 30.98, 23.62,
9.1, 18.17, 18.57, 10.15, 46.67, 34.27, 23.62, 54.17, 40.05,
29.37, 70.83, 59.17, 47.53, 8.67, 5.63, 0.87, 9.87, 3.03,
0, 17.75, 6.88, 0, 62.5, 37.5, 27.7, 70.83, 57.5, 50.83,
6.5, 2.17, 1.3, 6.93, 3.03, 0.53, 14.82, 5.2, 0, 37.5, 28.52,
13, 75, 37.5, 37.5, 15.3, 9.53, 5.63, 9.43, 3.03, 0.43, 16.4,
6.07, 0, 57.5, 34.23, 21.98, 78.33, 62.5, 37.5, 12.08, 6.5,
1.3, 10.73, 3.03, 0, 15.2, 3.9, 0.43, 62.5, 37.5, 21.98,
64.17, 55.83, 41.73, 8.73, 3.57, 0, 8.57, 2.17, 0, 16.5,
7.7, 0.43, 42.58, 36.68, 13, 65.83, 47.5, 37.5, 8.03, 5.07,
0.43, 10.68, 7.27, 3.5, 48.38, 38.42, 24.83, 45.03, 38.4,
30.8, 73.33, 63.33, 50.83, 3.37, 2.17, 0.9, 9, 6.02, 5.2,
21.07, 12.37, 6.02, 45.02, 32.65, 21.67, 68.78, 56.68, 50,
0, 0, 0, 7.8, 4.33, 4.33, 25.17, 20.65, 13.15, 48.37, 39.23,
27.17, 75.83, 62.5, 49, 11.78, 12.72, 3.8, 20.18, 14.87,
8.95, 46.7, 39.32, 33.03, 49.18, 40.05, 24.43, 69.17, 60,
48.33, 0, 0, 0, 15.25, 9.82, 7.75, 45.9, 38.47, 35.52, 50.88,
37.61, 33.47, 79.17, 71.67, 58.33)), .Names = c("Site", "Field",
"Leaf_Location", "Time", "Damage"), row.names = c(NA, -225L), class = "data.frame")
Here's a simplified reproducible example to explain
first, some dummy data:
per = data.frame(x=rep(c('a','b'), each=100), y=c(2+rnorm(100), 3+rnorm(100,0,2)))
Now you are plotting the error bars, using fun.ymin=min, fun.ymax=max, which will cause them to extend the full range of the data, as in the following graph:
ggplot(per, aes(x, y)) +
stat_summary(fun.y = mean, geom="bar") +
geom_point(position = position_jitter(0.1)) +
stat_summary(fun.ymin=min, fun.ymax=max, geom="errorbar", width=0.4) +
theme_bw()
Whereas, it is more conventional to use error bars that extend either +/- one standard deviation, as in the following:
ggplot(per, aes(x, y)) +
stat_summary(fun.y = mean, geom="bar") +
stat_summary(
fun.ymin=function(y) {mean(y) - sd(y)},
fun.ymax=function(y) {mean(y) + sd(y)},
geom="errorbar", width=0.2) +
theme_bw()
Or one standard error, like this:
ggplot(per, aes(x, y)) +
stat_summary(fun.y = mean, geom="bar") +
stat_summary(
fun.ymin=function(y) {mean(y) - sqrt(var(y)/length(y))},
fun.ymax=function(y) {mean(y) + sqrt(var(y)/length(y))},
geom="errorbar", width=0.2) +
theme_bw()
EDIT - example data were added to question, after this answer was originally posted
We can applying exactly the same approach as above to your example data:
ggplot(per, aes(x=Leaf_Location, y=Damage, fill=as.factor(Time))) +
stat_summary(fun.y=mean, geom="bar",position=position_dodge(),colour="black",width=.7,size=.7) +
stat_summary(
fun.ymin=function(y) {mean(y) - sqrt(var(y)/length(y))},
fun.ymax=function(y) {mean(y) + sqrt(var(y)/length(y))},
geom="errorbar",
position=position_dodge(.7), width=.2)
Good Day
Is it possible to produce a plot based on the output of a PAM dissimilarity clustering analysis with polygons drawn around the outer point of the clusters?
I have currently achieved something similar using the function clusplot however am more interested in seeing the clusters demarcated using straight lines.
# Installing packages
library(cluster)
library(fpc)
library(ggplot2)
library(ggfortify)
#Importing Koeberg matrix into R
KoebergAllCSV <- read.csv("C:/R/Koeberg Cluster/KoebergAllCSV.csv", row.names=1, sep=";")
#Checking if data is in the correct format/Checking class/mode of each column
sapply(KoebergAllCSV, mode)
sapply(KoebergAllCSV, class)
#Creating gower dissimilarity matrix using function "daisy"
#specifying variable type(numerics all ratioscaled and log transformed)
#and weighting all columns as 1
Koeberg.Diss = daisy(KoebergAllCSV, metric = "gower", type = list(logratio = c("Mass", "EF")), weights = rep.int(1,5))
attributes(Koeberg.Diss)
#Determine k
pamk(Koeberg.Diss, krange=2:50, criterion="asw", usepam=TRUE, scaling=FALSE, diss=TRUE, critout=FALSE)
#Run cluster analysis using PAM (Partitioning around medoids)
pam_fit= pam(Koeberg.Diss, diss = TRUE, k = 28)
#Export cluster info
KoebergClusInfo = paste("KoebergClusInfo", ".txt")
write.table(pam_fit$clustering, file = KoebergClusInfo, sep=",")
## Default S3 method:
clusplot(Koeberg.Diss, pam_fit$clustering, diss = TRUE,
stand = FALSE,
lines = 0, labels= 4, xlim = c(-1,1), plotchar = TRUE, span = TRUE,
shade = TRUE, color = TRUE, col.p = "black",
main = "Koeberg gower/pam Clusterplot",
verbose = getOption("verbose"))
I am aware that the function autoplot in ggplot2 accepts objects of class pam however when attempting to use it for my data and replacing the above clusplot function with
autoplot(pam(pam_fit), frame = TRUE)
or
autoplot(pam(Koeberg.Diss, diss = TRUE, k = 28), frame = TRUE)
I get the following errors...
Error in pam(pam_fit) : x is not a numeric dataframe or matrix.
and
Error in as.data.frame.default(x[[i]], optional = TRUE,
stringsAsFactors = stringsAsFactors) : cannot coerce class ""waiver""
to a data.frame Respectively...
I am relatively new to R and posting questions in these forums, so any help would be massively appreciated.
Edit: Got it to work using the fviz_cluster() in the factoextra package
# Installing packages
library(cluster)
library(fpc)
library(factoextra)
#Importing Koeberg matrix into R
KoebergAllCSV <- read.csv("C:/R/Koeberg Cluster/KoebergAllCSV.csv",
row.names=1, sep=";")
#creating gower dissimilarity matrix using daisy
Koeberg.Gower = as.matrix(daisy(KoebergAllCSV, metric = "gower", type =
list(logratio = c("Mass", "EF"))))
attributes(Koeberg.Gower)
pamk(Koeberg.Gower, krange=2:50, criterion="asw", usepam=TRUE,
scaling=FALSE, diss=TRUE, critout=FALSE)
Koeberg.Pam = pam(Koeberg.Gower, 28, diss = TRUE, keep.diss = TRUE)
fviz_cluster(object = list(data=Koeberg.Gower, cluster =
Koeberg.Pam$clustering), geom = c("point", "text"), ellipse.type =
"convex", stand = FALSE)
fviz_silhouette(silhouette(Koeberg.Pam))
# Installing packages
library(cluster)
library(fpc)
library(factoextra)
#Importing Koeberg matrix into R
KoebergAllCSV <- read.csv("C:/R/Koeberg Cluster/KoebergAllCSV.csv",
row.names=1, sep=";")
#creating gower dissimilarity matrix using daisy
Koeberg.Gower = as.matrix(daisy(KoebergAllCSV, metric = "gower", type =
list(logratio = c("Mass", "EF"))))
attributes(Koeberg.Gower)
pamk(Koeberg.Gower, krange=2:50, criterion="asw", usepam=TRUE,
scaling=FALSE, diss=TRUE, critout=FALSE)
Koeberg.Pam = pam(Koeberg.Gower, 28, diss = TRUE, keep.diss = TRUE)
fviz_cluster(object = list(data=Koeberg.Gower, cluster =
Koeberg.Pam$clustering), geom = c("point", "text"), ellipse.type =
"convex", stand = FALSE)
fviz_silhouette(silhouette(Koeberg.Pam))
Data used:
"KoebergAllCSV"
structure(list(Mass = c(157000, 775, 197, 15000, 3250, 628, 1815,
2070, 2000, 1218, 614, 536, 379, 235, 800, 672, 1960, 768, 1540,
1790, 3500, 7450, 4030, 2200, 830, 1180, 1310, 955, 590, 1168,
820, 790, 5000, 883, 824, 280, 184, 941, 293, 1250, 3900, 1700,
925, 220, 1040, 510, 690, 600, 539, 1018, 122, 1086, 118, 737,
370, 1236, 5820, 229, 226, 220, 305.5, 94.5, 390, 198, 445, 623,
1100, 377, 340, 418, 326, 202, 139, 47, 35.1, 46.1, 580, 1150,
66, 44, 50, 30, 34.2, 30, 91, 71, 59, 78.9, 110, 405, 19.5, 73,
64, 39, 54, 39, 37, 48, 21.2, 26.3, 24.2, 29, 15.2, 35, 16.1,
16.8, 29.7, 12.5, 55, 612, 630, 865, 22.4, 8.6, 47.3, 32.5, 28.8,
17.3, 38, 23.5, 22, 15.5, 18.1, 34, 23, 13.1, 13, 14.7, 19.1,
14, 18.6, 15.5, 37, 14.5, 24.6, 25, 28.5, 50.8, 52, 68.8, 76.1,
100, 85, 158, 113, 88, 25.6, 13, 10.2, 30.5, 38, 55, 45.5, 30,
52, 11, 17.8, 29, 13, 23.2, 38, 21, 25, 27.3, 427, 1572, 78.9,
15, 61, 212.9, 700, 11.1, 44, 29.6, 124, 3200, 5800, 5300, 950,
62.4, 205, 270, 93, 40.2, 102, 240, 90, 33, 16.6, 39.2, 47, 60.8,
13, 20.8, 8, 11, 165000, 180000, 63600, 11400, 21200, 41000,
11300, 840000, 240000, 320000, 900, 4090, 1250, 19000, 19000,
6400, 2610, 47, 4500, 1258, 238, 55, 113, 9990, 5360, 17800,
110.1973216, 238.1629085, 89.33169378, 245.0708356, 83.49190575,
7.323754897, 17.91558243, 2.259871723, 1.992123644, 78.63046291,
235.6804221, 413.5582987, 486.5966599, 7.418054089, 8.4510848,
8.4510848, 42.83324573, 8.4510848, 3.14445177, 2000, 496.2334891,
119.4158615, 805.4349144, 8.212468482, 25.0905618), Diet = structure(c(4L,
2L, 2L, 6L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 1L, 1L, 1L,
2L, 2L, 2L, 2L, 5L, 4L, 5L, 5L, 5L, 5L, 2L, 5L, 5L, 5L, 5L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 3L,
5L, 5L, 5L, 2L, 2L, 2L, 5L, 1L, 3L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
1L, 1L, 2L, 2L, 4L, 5L, 5L, 5L, 6L, 5L, 3L, 1L, 1L, 3L, 3L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L, 1L, 1L, 1L, 1L, 1L, 1L,
3L, 3L, 3L, 3L, 3L, 3L, 3L, 5L, 3L, 3L, 3L, 3L, 5L, 5L, 5L,
1L, 1L, 5L, 1L, 1L, 1L, 1L, 1L, 1L, 5L, 5L, 1L, 3L, 3L, 3L,
5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 3L, 3L, 5L, 5L, 5L, 1L,
3L, 5L, 5L, 3L, 3L, 5L, 5L, 5L, 5L, 3L, 5L, 5L, 5L, 5L, 5L,
5L, 5L, 5L, 3L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L,
5L, 5L, 5L, 5L, 5L, 2L, 5L, 3L, 5L, 5L, 5L, 5L, 5L, 5L, 2L,
2L, 1L, 1L, 5L, 5L, 2L, 2L, 5L, 2L, 1L, 5L, 3L, 5L, 1L, 3L,
5L, 5L, 5L, 1L, 3L, 3L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L,
5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 4L, 5L, 4L, 5L, 5L, 5L, 5L,
5L, 5L, 5L, 5L, 4L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 4L,
5L, 4L, 4L, 5L, 5L, 5L, 5L, 3L, 5L, 5L, 4L, 5L), .Label = c("Ae",
"Aq", "Ar", "Fo", "Te"), class = "factor"), EF = c(36274.12643,
974.5491757, 383.4606456, 15194.1663, 4179.125464, 1043.599331,
1739.739739, 1902.677158, 1858.620513, 1325.913225, 831.6334703,
758.1419376, 598.7459669, 432.4008244, 995.8492032, 1104.982804,
1833.224631, 968.5460848, 1555.574839, 2526.177199, 2720.81891,
4551.218864, 2995.035921, 1983.25768, 1021.131045, 1297.600326,
1393.320578, 1123.496167, 809.3558665, 1288.599252, 1012.736663,
987.3550419, 3468.868783, 1065.095472, 1016.098313, 487.1962293,
366.0414243, 1112.253632, 502.488525, 1349.53769, 2928.89833,
1663.891544, 1099.339465, 413.4082553, 1190.663398, 732.8997761,
900.420823, 818.6726853, 354.4240516, 652.168291, 85.2606497,
693.8895747, 270.483605, 941.7478954, 589.026282, 1339.226017,
3846.819879, 533.5361702, 528.1460593, 517.3161179, 666.1149499,
269.8814521, 803.9152978, 477.0047921, 889.8724349, 1153.045225,
1786.335023, 783.201274, 723.3180648, 640.0447608, 540.3690726,
390.0619447, 302.4004117, 144.5066856, 118.4522857, 142.6164524,
799.9885345, 1275.042111, 182.0952927, 543.7188737, 634.8358004,
341.8068213, 400.635478, 341.8068213, 1311.800923, 191.3798609,
168.7094925, 205.6358063, 257.8562828, 626.4208001, 79.37849663,
195.0348258, 178.3190991, 127.263627, 158.8361858, 127.263627,
122.7819915, 144.6363257, 82.97394225, 96.07341942, 90.78786186,
102.6748266, 66.17393783, 116.6808568, 68.813704, 70.83430724,
104.3536694, 57.93381766, 158.6645733, 816.6280747, 832.8847551,
1033.247332, 86.13942963, 44.9254345, 143.1986471, 110.9466069,
102.1927841, 72.26112014, 123.3917674, 88.99374555, 85.0904386,
67.05928121, 74.51689843, 114.4034188, 87.7017517, 59.81055334,
59.49970587, 64.68582581, 77.29226408, 62.57493448, 75.91055058,
67.05928121, 121.1742978, 64.08606129, 91.80560821, 92.81807245,
101.4677065, 150.3213487, 152.7269268, 184.7538415, 197.8677001,
238.2502359, 213.3232585, 325.1772534, 258.896799, 218.4145451,
94.32710718, 59.49970587, 50.45235653, 106.2569217, 123.3917674,
158.6645733, 139.4700925, 105.0692888, 152.7269268, 53.11049696,
73.67479581, 102.6748266, 59.49970587, 88.21961721, 123.3917674,
82.44084978, 92.81807245, 98.54258242, 649.397604, 1577.514936,
202.7896107, 65.58060147, 170.2384385, 404.275036, 909.2871722,
53.43834074, 136.3267745, 104.1146163, 265.4017335, 2559.743414,
3837.812585, 3609.284914, 1119.48705, 196.0571475, 393.9976926,
605.6763891, 266.5768403, 139.7476799, 286.2283703, 438.6449711,
224.9201933, 112.1044413, 70.25978867, 126.0282381, 142.5804177,
169.8586911, 59.49970587, 81.90613014, 42.76953519, 53.11049696,
44893.11086, 48012.29543, 21505.57155, 5704.435068, 9209.019243,
15323.26221, 5665.766265, 157697.8254, 59952.20689, 74861.38869,
616.5285774, 2297.756619, 820.2217331, 23289.68486, 8728.776034,
3390.680499, 1555.167143, 82.25108625, 2783.313695, 2329.752262,
567.6985933, 163.9110073, 301.8499294, 4992.739194, 2906.435392,
8247.673366, 12.81581191, 25.42711978, 10.63408241, 26.08172622,
10.0137771, 1.178076499, 2.549050089, 0.353356528, 0.31350088,
9.49371787, 25.19136319, 41.52955076, 47.98985328, 1.091673606,
1.235456699, 1.235456699, 5.76431571, 1.235456699, 0.483456886,
112.0018952, 48.83385255, 13.76461928, 75.11335195, 1.274157763,
3.438909954)), .Names = c("Mass", "Diet", "Time", "Space",
"EF"), class = "data.frame", row.names = c("CommonOstrich", "GreatCrestedGrebe",
"LittleGrebe", "GreatWhitePelican", "White-breastedCormorant",
"ReedCormorant", "AfricanDarter", "GreyHeron", "Black-headedHeron",
"PurpleHeron", "LittleEgret", "Yellow-billedEgret", "CattleEgret",
"Green-backedHeron", "Black-crownedNight-Heron", "HamerkopHamerkop",
"AfricanSacredIbis", "GlossyIbis", "HadedaIbis", "AfricanSpoonbill",
"GreaterFlamingo", "Spur-wingedGoose", "EgyptianGoose", "SouthAfricanShelduck",
"CapeShoveler", "AfricanBlackDuck", "Yellow-billedDuck", "Red-billedTeal",
"CapeTeal", "SouthernPochard", "MaccoaDuck", "White-backedDuck",
"Secretarybird", "PeregrineFalcon", "LannerFalcon", "RockKestrel",
"LesserKestrel", "Yellow-billedKite", "Black-shoulderedKite",
"BootedEagle", "AfricanFish-eagle", "JackalBuzzard", "SteppeBuzzard",
"Rufous-chestedSparrowhawk", "BlackSparrowhawk", "AfricanGoshawk",
"AfricanMarsh-harrier", "BlackHarrier", "Grey-wingedFrancolin",
"CapeSpurfowl", "CommonQuail", "HelmetedGuineafowl", "BlackCrake",
"AfricanPurpleSwamphen", "CommonMoorhen", "Red-knobbedCoot",
"BlueCrane", "CrownedLapwing", "BlacksmithLapwing", "RuffRuff",
"CommonGreenshank", "WoodSandpiper", "PiedAvocet", "Black-wingedStilt",
"WaterThick-knee", "SpottedThick-knee", "KelpGull", "Grey-headedGull",
"Hartlaub'sGull", "SpeckledPigeon", "Red-eyedDove", "CapeTurtle-dove",
"LaughingDove", "NamaquaDove", "Klaas'sCuckoo", "DiderickCuckoo",
"BarnOwl", "SpottedEagle-owl", "Fiery-neckedNightjar", "CommonSwift",
"AfricanBlackSwift", "White-rumpedSwift", "HorusSwift", "LittleSwift",
"AlpineSwift", "SpeckledMousebird", "White-backedMousebird",
"Red-facedMousebird", "PiedKingfisher", "GiantKingfisher", "MalachiteKingfisher",
"EuropeanBee-eater", "AfricanHoopoe", "AcaciaPiedBarbet", "GreaterHoneyguide",
"LesserHoneyguide", "CardinalWoodpecker", "Large-billedLark",
"Grey-backedSparrowlark", "Red-cappedLark", "BarnSwallow", "White-throatedSwallow",
"Pearl-breastedSwallow", "GreaterStripedSwallow", "RockMartin",
"Brown-throatedMartin", "BandedMartin", "Black(Southernrace)Saw-wing",
"Fork-tailedDrongo", "PiedCrow", "CapeCrow", "White-neckedRaven",
"GreyTit", "CapePenduline-tit", "CapeBulbul", "CappedWheatear",
"FamiliarChat", "AfricanStonechat", "CapeRobin-chat", "KarooScrub-robin",
"LesserSwamp-warbler", "AfricanReed-warbler", "LittleRush-warbler",
"CapeGrassbird", "Long-billedCrombec", "Bar-throatedApalis",
"CloudCisticola", "Grey-backedCisticola", "Levaillant'sCisticola",
"AfricanDuskyFlycatcher", "Chestnut-ventedTit-babbler", "Layard'sTit-babbler",
"FiscalFlycatcher", "CapeBatis", "AfricanParadise-flycatcher",
"CapeWagtail", "AfricanPipit", "CapeLongclaw", "Common(Southern)Fiscal",
"SouthernBoubou", "Bokmakierie", "CommonStarling", "WattledStarling",
"Red-wingedStarling", "PiedStarling", "CapeSugarbird", "MalachiteSunbird",
"Orange-breastedSunbird", "SouthernDouble-collaredSunbird", "HouseSparrow",
"CapeSparrow", "CapeWeaver", "SouthernMasked-weaver", "SouthernRedBishop",
"YellowBishop", "CommonWaxbill", "Pin-tailedWhydah", "CapeCanary",
"Black-headedCanary", "BrimstoneCanary", "White-throatedCanary",
"YellowCanary", "Streaky-headedSeedeater", "CapeBunting", "RockDove",
"MallardDuck", "OliveThrush", "CapeWhite-eye", "CapeLong-billedLark",
"Burchell'sCoucal", "SouthernBlackKorhaan", "KarooPrinia", "CapeClapperLark",
"SouthernGrey-headedSparrow", "LittleBittern", "BlackStork",
"Verreaux'sEagle", "MartialEagle", "AfricanHarrier-Hawk", "BlackrumpedButtonquail",
"AfricanRail", "AfricanJacana", "CommonSandpiper", "LittleStint",
"White-wingedTern", "NamaquaSandgrouse", "Red-chestedCuckoo",
"KarooLark", "SandMartin", "SombreGreenbul", "MountainChat",
"Ant-eatingChat", "ZittingCisticola", "SpottedFlycatcher", "FairyFlycatcher",
"DuskySunbird", "RedHartebeest", "BlueWildebeest", "Bontebok",
"CapeGrysbok", "CommonDuiker", "Springbok", "Steenbok", "CommonEland",
"Gemsbok", "PlainsZebra", "YellowMongoose", "LargeGreyMongoose",
"SmallGreyMongoose", "CapePorcupine", "Caracal", "AfricanWildCat",
"Small-spottedGenet", "CapeGoldenMole", "ScrubHare", "CapeDuneMole-Rat",
"VleiRat", "FourStripedGrassMouse", "CapeGerbil", "Black-BackedJackal",
"Bat-earedFox", "AfricanClawlessOtter", "HeraldSnake", "RhombicEgg-eater",
"SpottedHarlequinSnake", "OliveHouseSnake", "SpottedHouseSnake",
"Knox'sDesertLizard", "NamaquaDwarfChameleon", "Austen'sThick-toedGecko",
"OcelatedThick-toedGecko", "CrossedWhipSnake", "CapeWhipSnake",
"Spotted/RhombicSkaapsteker", "MoleSnake", "Short-leggedseps",
"SilveryDwarfBurrowingSkink", "BloubergDwarfBurrowingSkink",
"CapeSkink", "Red-SidedSkink", "VariegatedSkink", "AngulateTortoise",
"Boomslang", "KarooWhipSnake", "CapeCobra", "Delalande'sBeakedBlindSnake",
"CapeGirdledLizard"))
I'm trying to create a facet wrapped ggplot boxplot with dataframe dataw and I'm trying to modify the labels of each subplot.
dataw <- structure(list(base = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L,
3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 4L, 4L, 4L, 4L, 4L, 4L,
4L, 4L, 4L, 4L, 4L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L,
3L, 3L, 3L, 3L, 3L, 3L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L,
4L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L,
3L, 3L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 4L, 4L,
4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L,
3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 4L, 4L, 4L, 4L, 4L, 4L,
4L, 4L, 4L, 4L, 4L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,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, 5L, 5L, 5L, 5L, 5L, 5L, 6L, 6L, 6L, 6L, 6L,
6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L,
6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L,
6L, 6L, 6L, 6L, 6L, 6L, 6L), values = c(13, 22, 16, 21, 52, 1,
1.709, 2.121, 2.061, 2.233, 3.388, 1, 5, 6, 6, 2, 1, 0.856, 1.116,
1.207, 1.175, 0.95, 76, 45, 5, 1, 1, 15, 8.558, 5.44, 1.147,
0.857, 0.831, 10, 7, 40, 4, 10, 5, 1.547, 1.174, 4.777, 1.071,
1.356, 7, 0, 1, 6, 1, 8, 1.322, 0.728, 0.83, 1.178, 0.831, 4,
2, 0, 1, 3, 0, 1.098, 0.96, 0.63, 0.888, 1.013, 13, 22, 16, 21,
52, 1, 1.709, 2.121, 2.061, 2.233, 3.388, 3, 6, 7, 2, 9, 11,
0.952, 1.474, 1.45, 0.967, 1.306, 13, 22, 16, 21, 52, 1, 1.709,
2.121, 2.061, 2.233, 3.388, 3, 8, 15, 0, 5, 2, 1.014, 1.583,
2.289, 0.773, 1.135, 10, 3, 8, 1, 4, 2, 1.504, 1.03, 1.244, 0.884,
1.047, 4, 1, 0, 2, 5, 1, 1.066, 0.862, 0.689, 0.963, 1.125, 2,
0, 0, 2, 0, 1, 0.919, 0.723, 0.479, 0.922, 0.721, 7, 8, 0, 8,
7, 0, 1.299, 1.236, 0.779, 1.298, 1.224, 13, 22, 16, 21, 52,
1, 1.709, 2.121, 2.061, 2.233, 3.388, 45, 38, 41, 13, 34, 1,
2.817, 2.264, 2.398, 1.374, 3.848, 3, 0, 1, 1, 2, 14, 0.973,
0.641, 0.846, 0.866, 0.909, 13, 22, 16, 21, 52, 1, 1.709, 2.121,
2.061, 2.233, 3.388, 7, 0, 0, 1, 2, 1, 1.37, 0.436, 0.706, 0.685,
0.902, 0,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L, 5L, 5L, 5L,
5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L,
5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L,
5L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L,
6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L,
6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L
), .Label = c("D<U+2192>", "G<U+2192>", "A<U+2192>", "K<U+2192>",
"C<U+2192>", "T<U+2192>"), class = "factor")), .Names = c("base",
"pos", "values", "type", "labels"), row.names = c("1", "2", "3",
"4", "5", "3942", "3943", "3944", "3945", "3946", "3947", "11",
"21", "31", "41", "51", "63", "64", "65", "66", "67", "68", "12",
"22", "32", "42", "52", "2953", "2954", "2955", "2956", "2957",
"2958", "13", "23", "33", "43", "53", "2461", "2462", "2463",
"2464", "2465", "2466", "14", "24", "34", "44", "54", "7493",
"7494", "7495", "7496", "7497", "7498", "111", "214", "311",
"411", "511", "4874", "4875", "4876", "4877", "4878", "4879",
"121", "221", "321", "421", "521", "9356", "9357", "9358", "9359",
"9360", "9361", "131", "231", "331", "431", "531", "9221", "9222",
"9223", "9224", "9225", "9226", "15", "25", "35", "45", "55",
"93561", "93571", "93581", "93591", "93601", "93611", "112",
"215", "312", "412", "512", "1579", "1580", "1581", "1582", "1583",
"1584", "122", "222", "322", "422", "522", "1782", "1783", "1784",
"1785", "1786", "1787", "132", "232", "332", "432", "532", "3398",
"3399", "3400", "3401", "3402", "3403", "16", "26", "36", "46",
"56", "2257", "2258", "2259", "2260", "2261", "2262", "113",
"216", "313", "413", "513", "1027", "1028", "1029", "1030", "1031",
"1032", "123", "223", "323", "423", "523", "8654", "8655", "8656",
"8657", "8658", "8659", "133", "233", "333", "433", "539", "702",
"703", "704", "705", "706", "707", "17", "27", "37", "47", "57",
"8123", "8124", "8125", "8126", "8127", "8128", "114", "217",
"314", "414", "514", "93562", "93572", "93582", "93592", "93602",
"93612", "124", "224", "324", "424", "524", "3700", "3701", "3702",
"3703", "3704", "3705", "134", "234", "334", "434", "5310", "8233",
"8234", "8235", "8236", "8237", "8238", "18", "28", "38", "48",
"58", "1542", "1543", "1544", "1545", "1546", "1547", "115",
"218", "315", "415", "515", "533", "534", "535", "536", "537",
"538", "125", "225", "325", "425", "525", "208", "209", "210",
"211", "212", "213", "135", "235", "335", "435", "5311", "93563",
"93573", "93583", "93593", "93603", "93613"), class = "data.frame")
These are the first few rows of dataw
head(dataw)
base pos values type labels
1 A 1 13 score D<U+2192>
2 A 1 22 score D<U+2192>
3 A 1 16 score D<U+2192>
4 A 1 21 score D<U+2192>
5 A 1 52 score D<U+2192>
3942 A 1 1 score D<U+2192>
I'm plotting it like so.
prettify <- theme(panel.background = element_rect(fill = NA,color="gray"),
panel.grid.major.y = element_blank(),
panel.grid.major.x = element_line(size=.1, color="black",linetype="dotted"),
panel.grid.minor.y = element_blank(),
panel.grid.minor.x = element_line(size=.1, color="black"),
legend.position="bottom")
ggplot(dataw,aes(x = base, y = values, color = type, group = base)) +
geom_boxplot() +
facet_wrap(type ~ pos, scales="free_y", nrow = 2) +
theme_gray() %+replace% prettify
Currently the sublabels are the type value followed by a comma and the pos value. However I would like to get rid of the type value, and label it so that the labels of each subplot are in the format: "Position [pos value], [labels value]"
What would be the best way to go about this? Thank you.
Try replacing the entire ggplot statement with
ggplot(data=transform(dataw, plt_labels = paste("Position ", pos, ", ", labels, sep="")),aes(x = base, y = values, color = type, group = base)) +
geom_boxplot() +
facet_grid(type ~ plt_labels, scales="free_y") +
theme_gray() %+replace% prettify
which should give