I have question to you guys because I don't know how to interpolate my data on map.
I'm try to reproduce map from http://aasa.ut.ee/Rspatial/05_session.html and I want to achive something like that:
map from tutorial. But there is happening something in background so I don't understand everything.
What I already have:
data frame with longitude, latitude and preassure columns.
The range of longitude and latitude is xlim=c(-10, 30), ylim=c(40,65)
> df
longitude latitude preassure
1 65.0 -10.0 999.6984
2 65.0 -7.5 999.7445
3 65.0 -5.0 999.5182
4 65.0 -2.5 999.0021
5 65.0 0.0 998.4595
6 65.0 2.5 998.0452
7 65.0 5.0 997.8119
8 65.0 7.5 997.4956
9 65.0 10.0 997.1532
10 65.0 12.5 997.1851
11 65.0 15.0 997.3216
12 65.0 17.5 997.0767
13 65.0 20.0 996.5215
14 65.0 22.5 996.0055
15 65.0 25.0 995.7271
16 65.0 27.5 995.6919
17 65.0 30.0 995.8885
18 65.0 32.5 996.1016
19 65.0 35.0 996.3514
20 62.5 -10.0 1001.9770
21 62.5 -7.5 1002.4431
22 62.5 -5.0 1002.6335
23 62.5 -2.5 1002.6905
24 62.5 0.0 1002.7607
25 62.5 2.5 1002.7090
26 62.5 5.0 1002.2872
27 62.5 7.5 1001.8760
28 62.5 10.0 1001.8066
29 62.5 12.5 1001.3829
30 62.5 15.0 1000.1226
31 62.5 17.5 998.7299
32 62.5 20.0 997.8351
33 62.5 22.5 997.3430
34 62.5 25.0 997.2307
35 62.5 27.5 997.3709
36 62.5 30.0 997.5797
37 62.5 32.5 997.7341
38 62.5 35.0 997.9541
39 60.0 -10.0 1006.7589
40 60.0 -7.5 1007.3146
41 60.0 -5.0 1007.5654
42 60.0 -2.5 1007.7268
43 60.0 0.0 1007.8035
44 60.0 2.5 1007.5192
45 60.0 5.0 1006.9113
46 60.0 7.5 1006.3931
47 60.0 10.0 1005.7369
48 60.0 12.5 1004.3599
49 60.0 15.0 1002.6407
50 60.0 17.5 1001.2952
51 60.0 20.0 1000.2639
52 60.0 22.5 999.5920
53 60.0 25.0 999.3969
54 60.0 27.5 999.3746
55 60.0 30.0 999.4167
56 60.0 32.5 999.6822
57 60.0 35.0 1000.2075
58 57.5 -10.0 1011.8321
59 57.5 -7.5 1012.5412
60 57.5 -5.0 1013.0607
61 57.5 -2.5 1013.2542
62 57.5 0.0 1013.0942
63 57.5 2.5 1012.6132
64 57.5 5.0 1011.7856
65 57.5 7.5 1010.6275
66 57.5 10.0 1009.2998
67 57.5 12.5 1007.9899
68 57.5 15.0 1006.7288
69 57.5 17.5 1005.4613
70 57.5 20.0 1004.2938
71 57.5 22.5 1003.5243
72 57.5 25.0 1003.2300
73 57.5 27.5 1003.0484
74 57.5 30.0 1002.9350
75 57.5 32.5 1003.1247
76 57.5 35.0 1003.6449
77 55.0 -10.0 1017.0270
78 55.0 -7.5 1018.0844
79 55.0 -5.0 1018.8001
80 55.0 -2.5 1018.8523
81 55.0 0.0 1018.3936
82 55.0 2.5 1017.8593
83 55.0 5.0 1017.3493
84 55.0 7.5 1016.5559
85 55.0 10.0 1015.3215
86 55.0 12.5 1013.9338
87 55.0 15.0 1012.6094
88 55.0 17.5 1011.2712
89 55.0 20.0 1009.9580
90 55.0 22.5 1008.9790
91 55.0 25.0 1008.4529
92 55.0 27.5 1008.0782
93 55.0 30.0 1007.7059
94 55.0 32.5 1007.5469
95 55.0 35.0 1007.5681
96 52.5 -10.0 1021.5118
97 52.5 -7.5 1022.4463
98 52.5 -5.0 1022.9901
99 52.5 -2.5 1023.1570
100 52.5 0.0 1023.0451
101 52.5 2.5 1022.8766
102 52.5 5.0 1022.7153
103 52.5 7.5 1022.2165
104 52.5 10.0 1021.0707
105 52.5 12.5 1019.6818
106 52.5 15.0 1018.5007
107 52.5 17.5 1017.3067
108 52.5 20.0 1015.8635
109 52.5 22.5 1014.5103
110 52.5 25.0 1013.4495
111 52.5 27.5 1012.4800
112 52.5 30.0 1011.7438
113 52.5 32.5 1011.5841
114 52.5 35.0 1011.6581
115 50.0 -10.0 1024.6059
116 50.0 -7.5 1025.4720
117 50.0 -5.0 1026.0310
118 50.0 -2.5 1026.4533
119 50.0 0.0 1026.6738
120 50.0 2.5 1026.6087
121 50.0 5.0 1026.4604
122 50.0 7.5 1026.2937
123 50.0 10.0 1025.5823
124 50.0 12.5 1024.3837
125 50.0 15.0 1023.3542
126 50.0 17.5 1022.3630
127 50.0 20.0 1021.0361
128 50.0 22.5 1019.7546
129 50.0 25.0 1018.5380
130 50.0 27.5 1016.9760
131 50.0 30.0 1015.5891
132 50.0 32.5 1015.2455
133 50.0 35.0 1015.3957
134 47.5 -10.0 1026.5579
135 47.5 -7.5 1027.6550
136 47.5 -5.0 1028.1215
137 47.5 -2.5 1028.2034
138 47.5 0.0 1028.3665
139 47.5 2.5 1028.4254
140 47.5 5.0 1028.6371
141 47.5 7.5 1029.1085
142 47.5 10.0 1028.8970
143 47.5 12.5 1027.6374
144 47.5 15.0 1026.1353
145 47.5 17.5 1024.8384
146 47.5 20.0 1023.6115
147 47.5 22.5 1022.7498
148 47.5 25.0 1022.1981
149 47.5 27.5 1020.5934
150 47.5 30.0 1018.6138
151 47.5 32.5 1017.7399
152 47.5 35.0 1017.6530
153 45.0 -10.0 1027.3521
154 45.0 -7.5 1028.1177
155 45.0 -5.0 1028.4873
156 45.0 -2.5 1028.4996
157 45.0 0.0 1028.7896
158 45.0 2.5 1028.8341
159 45.0 5.0 1027.7460
160 45.0 7.5 1026.4421
161 45.0 10.0 1025.6955
162 45.0 12.5 1025.1825
163 45.0 15.0 1025.0429
164 45.0 17.5 1025.2959
165 45.0 20.0 1025.0541
166 45.0 22.5 1024.3106
167 45.0 25.0 1022.9915
168 45.0 27.5 1021.3729
169 45.0 30.0 1020.4743
170 45.0 32.5 1019.7272
171 45.0 35.0 1019.3080
172 42.5 -10.0 1027.2090
173 42.5 -7.5 1027.8139
174 42.5 -5.0 1028.9445
175 42.5 -2.5 1029.2019
176 42.5 0.0 1028.4393
177 42.5 2.5 1026.8987
178 42.5 5.0 1025.0419
179 42.5 7.5 1023.9250
180 42.5 10.0 1024.0046
181 42.5 12.5 1024.0845
182 42.5 15.0 1023.5381
183 42.5 17.5 1023.5317
184 42.5 20.0 1024.7725
185 42.5 22.5 1025.0638
186 42.5 25.0 1022.9272
187 42.5 27.5 1022.0318
188 42.5 30.0 1021.7181
189 42.5 32.5 1020.8714
190 42.5 35.0 1020.5228
191 40.0 -10.0 1026.8144
192 40.0 -7.5 1027.3171
193 40.0 -5.0 1029.2556
194 40.0 -2.5 1028.9006
195 40.0 0.0 1026.9173
196 40.0 2.5 1026.1678
197 40.0 5.0 1025.5287
198 40.0 7.5 1024.6530
199 40.0 10.0 1024.0673
200 40.0 12.5 1023.5342
201 40.0 15.0 1022.7612
202 40.0 17.5 1022.1834
203 40.0 20.0 1022.2757
204 40.0 22.5 1022.6448
205 40.0 25.0 1021.9519
206 40.0 27.5 1021.6179
207 40.0 30.0 1022.3322
208 40.0 32.5 1023.9349
209 40.0 35.0 1023.3993
here is my code:
library("rnaturalearth")
library(sf)
library(ggplot2)
library(viridis)
world <- ne_countries(scale = "medium", returnclass = "sf")
sf::sf_use_s2(FALSE)
ggplot(data = world) +
geom_raster(data = df, aes(x=latitude, y=longitude, fill=preassure), interpolate = TRUE) +
scale_fill_viridis(direction = 1) +
geom_sf(fill = "NA", colour = "white") +
coord_sf(xlim=c(-10, 30),ylim=c(40,65), expand = F) +
xlab("Długość geograficzna") + ylab("Szerokość geograficzna") +
labs(title = "SLP zima",fill = "Cisnienie") +
theme(plot.title = element_text(hjust = 0.5)
)
and result: what I was able to do
and finaly I want something like this:
map with the preasure interpolation - demo from paint
Thanks for all your help!!!
Related
The dataset called bodyfat.csv, I attached the data set in plain text for your reference.
After reading in bodyfat.csv data file, I generated a variable "bodycat" to categorize "bodyfat" into the three categories "athlete", "average", or "obese". (Athlete, less than 14%, Average, 14-25%, Obese, greater than 25%).
Then I use Using summary to identify the four height quartiles, create a new variable "htcat" to categorize height into "short", "below average", "above average", and "tall".
Now I want to use aggregate(weight ~ bodycat * htcat, .. ) to create a barplot of the average weight for each height and body category.
bodydata <- read.csv("bodyfat.csv",header=T)
bodycat <- c()
bodycat[bodydata$bodyfat<14]<-"Athlete"
bodycat[bodydata$bodyfat>=14 & bodydata$bodyfat<25]<-"Average"
bodycat[bodydata$bodyfat>=25]<-"Obese"
bodydata <-cbind(bodydata,bodycat)
summary(bodydata)
summary(bodydata$height)
htcat <- c()
htcat[bodydata$height>=29.50 & bodydata$height<68.25]<-"short"
htcat[bodydata$height>=68.25 & bodydata$height<70.00]<-"below average"
htcat[bodydata$height>=70.00 & bodydata$height<72.25]<-"above average"
htcat[bodydata$height>=72.25 & bodydata$height<77.75]<-"tall"
bodydata <-cbind(bodydata,htcat)
avgweightpercat<-aggregate(weight~bodycat*htcat, data=bodydata, FUN = mean)
barplot(avgweightpercat$weight, ylab = "Average weight", names.arg = (avgweightpercat$bodycat)*(avgweightpercat$htcat), col = "red", main = "Average weight per bodycat and htcat")
I got this plot and received an error:
Warning message:
In Ops.factor((avgweightpercat$bodycat), (avgweightpercat$htcat)) :
‘*’ not meaningful for factors
What did I do wrong? How you do it in this case?
bodyfat.csv in plain text
id bodyfat density age weight height adiposity neck chest abdomen hip thigh knee ankle bicep forearm wrist
1 12.6 1.0708 23 154.25 67.75 23.7 36.2 93.1 85.2 94.5 59 37.3 21.9 32 27.4 17.1
2 6.9 1.0853 22 173.25 72.25 23.4 38.5 93.6 83 98.7 58.7 37.3 23.4 30.5 28.9 18.2
3 24.6 1.0414 22 154 66.25 24.7 34 95.8 87.9 99.2 59.6 38.9 24 28.8 25.2 16.6
4 10.9 1.0751 26 184.75 72.25 24.9 37.4 101.8 86.4 101.2 60.1 37.3 22.8 32.4 29.4 18.2
5 27.8 1.034 24 184.25 71.25 25.6 34.4 97.3 100 101.9 63.2 42.2 24 32.2 27.7 17.7
6 20.6 1.0502 24 210.25 74.75 26.5 39 104.5 94.4 107.8 66 42 25.6 35.7 30.6 18.8
7 19 1.0549 26 181 69.75 26.2 36.4 105.1 90.7 100.3 58.4 38.3 22.9 31.9 27.8 17.7
8 12.8 1.0704 25 176 72.5 23.6 37.8 99.6 88.5 97.1 60 39.4 23.2 30.5 29 18.8
9 5.1 1.09 25 191 74 24.6 38.1 100.9 82.5 99.9 62.9 38.3 23.8 35.9 31.1 18.2
10 12 1.0722 23 198.25 73.5 25.8 42.1 99.6 88.6 104.1 63.1 41.7 25 35.6 30 19.2
11 7.5 1.083 26 186.25 74.5 23.6 38.5 101.5 83.6 98.2 59.7 39.7 25.2 32.8 29.4 18.5
12 8.5 1.0812 27 216 76 26.3 39.4 103.6 90.9 107.7 66.2 39.2 25.9 37.2 30.2 19
13 20.5 1.0513 32 180.5 69.5 26.3 38.4 102 91.6 103.9 63.4 38.3 21.5 32.5 28.6 17.7
14 20.8 1.0505 30 205.25 71.25 28.5 39.4 104.1 101.8 108.6 66 41.5 23.7 36.9 31.6 18.8
15 21.7 1.0484 35 187.75 69.5 27.4 40.5 101.3 96.4 100.1 69 39 23.1 36.1 30.5 18.2
16 20.5 1.0512 35 162.75 66 26.3 36.4 99.1 92.8 99.2 63.1 38.7 21.7 31.1 26.4 16.9
17 28.1 1.0333 34 195.75 71 27.3 38.9 101.9 96.4 105.2 64.8 40.8 23.1 36.2 30.8 17.3
18 22.4 1.0468 32 209.25 71 29.2 42.1 107.6 97.5 107 66.9 40 24.4 38.2 31.6 19.3
19 16.1 1.0622 28 183.75 67.75 28.2 38 106.8 89.6 102.4 64.2 38.7 22.9 37.2 30.5 18.5
20 16.5 1.061 33 211.75 73.5 27.6 40 106.2 100.5 109 65.8 40.6 24 37.1 30.1 18.2
21 19 1.0551 28 179 68 27.3 39.1 103.3 95.9 104.9 63.5 38 22.1 32.5 30.3 18.4
22 15.3 1.064 28 200.5 69.75 29.1 41.3 111.4 98.8 104.8 63.4 40.6 24.6 33 32.8 19.9
23 15.7 1.0631 31 140.25 68.25 21.2 33.9 86 76.4 94.6 57.4 35.3 22.2 27.9 25.9 16.7
24 17.6 1.0584 32 148.75 70 21.4 35.5 86.7 80 93.4 54.9 36.2 22.1 29.8 26.7 17.1
25 14.2 1.0668 28 151.25 67.75 23.2 34.5 90.2 76.3 95.8 58.4 35.5 22.9 31.1 28 17.6
26 4.6 1.0911 27 159.25 71.5 21.9 35.7 89.6 79.7 96.5 55 36.7 22.5 29.9 28.2 17.7
27 8.5 1.0811 34 131.5 67.5 20.3 36.2 88.6 74.6 85.3 51.7 34.7 21.4 28.7 27 16.5
28 22.4 1.0468 31 148 67.5 22.9 38.8 97.4 88.7 94.7 57.5 36 21 29.2 26.6 17
29 4.7 1.091 27 133.25 64.75 22.4 36.4 93.5 73.9 88.5 50.1 34.5 21.3 30.5 27.9 17.2
30 9.4 1.079 29 160.75 69 23.8 36.7 97.4 83.5 98.7 58.9 35.3 22.6 30.1 26.7 17.6
31 12.3 1.0716 32 182 73.75 23.6 38.7 100.5 88.7 99.8 57.5 38.7 33.9 32.5 27.7 18.4
32 6.5 1.0862 29 160.25 71.25 22.2 37.3 93.5 84.5 100.6 58.5 38.8 21.5 30.1 26.4 17.9
33 13.4 1.0719 27 168 71.25 23.3 38.1 93 79.1 94.5 57.3 36.2 24.5 29 30 18.8
34 20.9 1.0502 41 218.5 71 30.5 39.8 111.7 100.5 108.3 67.1 44.2 25.2 37.5 31.5 18.7
35 31.1 1.0263 41 247.25 73.5 32.2 42.1 117 115.6 116.1 71.2 43.3 26.3 37.3 31.7 19.7
36 38.2 1.0101 49 191.75 65 32 38.4 118.5 113.1 113.8 61.9 38.3 21.9 32 29.8 17
37 23.6 1.0438 40 202.25 70 29.1 38.5 106.5 100.9 106.2 63.5 39.9 22.6 35.1 30.6 19
38 27.5 1.0346 50 196.75 68.25 29.7 42.1 105.6 98.8 104.8 66 41.5 24.7 33.2 30.5 19.4
39 33.8 1.0202 46 363.15 72.25 48.9 51.2 136.2 148.1 147.7 87.3 49.1 29.6 45 29 21.4
40 31.3 1.0258 50 203 67 31.8 40.2 114.8 108.1 102.5 61.3 41.1 24.7 34.1 31 18.3
41 33.1 1.0217 45 262.75 68.75 39.1 43.2 128.3 126.2 125.6 72.5 39.6 26.6 36.4 32.7 21.4
42 31.7 1.025 44 205 29.5 29.9 36.6 106 104.3 115.5 70.6 42.5 23.7 33.6 28.7 17.4
43 30.4 1.0279 48 217 70 31.2 37.3 113.3 111.2 114.1 67.7 40.9 25 36.7 29.8 18.4
44 30.8 1.0269 41 212 71.5 29.2 41.5 106.6 104.3 106 65 40.2 23 35.8 31.5 18.8
45 8.4 1.0814 39 125.25 68 19.1 31.5 85.1 76 88.2 50 34.7 21 26.1 23.1 16.1
46 14.1 1.067 43 164.25 73.25 21.3 35.7 96.6 81.5 97.2 58.4 38.2 23.4 29.7 27.4 18.3
47 11.2 1.0742 40 133.5 67.5 20.6 33.6 88.2 73.7 88.5 53.3 34.5 22.5 27.9 26.2 17.3
48 6.4 1.0665 39 148.5 71.25 20.6 34.6 89.8 79.5 92.7 52.7 37.5 21.9 28.8 26.8 17.9
49 13.4 1.0678 45 135.75 68.5 20.4 32.8 92.3 83.4 90.4 52 35.8 20.6 28.8 25.5 16.3
50 5 1.0903 47 127.5 66.75 20.2 34 83.4 70.4 87.2 50.6 34.4 21.9 26.8 25.8 16.8
51 10.7 1.0756 47 158.25 72.25 21.3 34.9 90.2 86.7 98.3 52.6 37.2 22.4 26 25.8 17.3
52 7.4 1.084 40 139.25 69 20.6 34.3 89.2 77.9 91 51.4 34.9 21 26.7 26.1 17.2
53 8.7 1.0807 51 137.25 67.75 21.1 36.5 89.7 82 89.1 49.3 33.7 21.4 29.6 26 16.9
54 7.1 1.0848 49 152.75 73.5 19.9 35.1 93.3 79.6 91.6 52.6 37.6 22.6 38.5 27.4 18.5
55 4.9 1.0906 42 136.25 67.5 21.1 37.8 87.6 77.6 88.6 51.9 34.9 22.5 27.7 27.5 18.5
56 22.2 1.0473 54 198 72 26.9 39.9 107.6 100 99.6 57.2 38 22 35.9 30.2 18.9
57 20.1 1.0524 58 181.5 68 27.6 39.1 100 99.8 102.5 62.1 39.6 22.5 33.1 28.3 18.5
58 27.1 1.0356 62 201.25 69.5 29.3 40.5 111.5 104.2 105.8 61.8 39.8 22.7 37.7 30.9 19.2
59 30.4 1.028 54 202.5 70.75 28.4 40.5 115.4 105.3 97 59.1 38 22.5 31.6 28.8 18.2
60 24 1.043 61 179.75 65.75 29.2 38.4 104.8 98.3 99.6 60.6 37.7 22.9 34.5 29.6 18.5
61 25.4 1.0396 62 216 73.25 28.2 41.4 112.3 104.8 103.1 61.6 40.9 23.1 36.2 31.8 20.2
62 28.8 1.0317 56 178.75 68.5 26.8 35.6 102.9 94.7 100.8 60.9 38 22.1 32.5 29.8 18.3
63 29.6 1.0298 54 193.25 70.25 27.6 38 107.6 102.4 99.4 61 39.4 23.6 32.7 29.9 19.1
64 25.1 1.0403 61 178 67 27.9 37.4 105.3 99.7 99.7 60.8 40.1 22.7 33.6 29 18.8
65 31 1.0264 57 205.5 70 29.5 40.1 105.3 105.5 108.3 65 41.2 24.7 35.3 31.1 18.4
66 28.9 1.0313 55 183.5 67.5 28.3 40.9 103 100.3 104.2 64.8 40.2 22.7 34.8 30.1 18.7
67 21.1 1.0499 54 151.5 70.75 21.3 35.6 90 83.9 93.9 55 36.1 21.7 29.6 27.4 17.4
68 14 1.0673 55 154.75 71.5 21.3 36.9 95.4 86.6 91.8 54.3 35.4 21.5 32.8 27.4 18.7
69 7.1 1.0847 54 155.25 69.25 22.8 37.5 89.3 78.4 96.1 56 37.4 22.4 32.6 28.1 18.1
70 13.2 1.0693 55 156.75 71.5 21.6 36.3 94.4 84.6 94.3 51.2 37.4 21.6 27.3 27.1 17.3
71 23.7 1.0439 62 167.5 71.5 23.1 35.5 97.6 91.5 98.5 56.6 38.6 22.4 31.5 27.3 18.6
72 9.4 1.0788 55 146.75 68.75 21.9 38.7 88.5 82.8 95.5 58.9 37.6 21.6 30.3 27.3 18.3
73 9.1 1.0796 56 160.75 73.75 20.8 36.4 93.6 82.9 96.3 52.9 37.5 23.1 29.7 27.3 18.2
74 13.7 1.068 55 125 64 21.5 33.2 87.7 76 88.6 50.9 35.4 19.1 29.3 25.7 16.9
75 12 1.072 61 143 65.75 23.3 36.5 93.4 83.3 93 55.5 35.2 20.9 29.4 27 16.8
76 18.3 1.0666 61 148.25 67.5 22.9 36 91.6 81.8 94.8 54.5 37 21.4 29.3 27 18.3
77 9.2 1.079 57 162.5 69.5 23.7 38.7 91.6 78.8 94.3 56.7 39.7 24.2 30.2 29.2 18.1
78 21.7 1.0483 69 177.75 68.5 26.7 38.7 102 95 98.3 55 38.3 21.8 30.8 25.7 18.8
79 21.1 1.0498 81 161.25 70.25 23 37.8 96.4 95.4 99.3 53.5 37.5 21.5 31.4 26.8 18.3
80 18.6 1.056 66 171.25 69.25 25.1 37.4 102.7 98.6 100.2 56.5 39.3 22.7 30.3 28.7 19
81 30.2 1.0283 67 163.75 67.75 25.1 38.4 97.7 95.8 97.1 54.8 38.2 23.7 29.4 27.2 19
82 26 1.0382 64 150.25 67.25 23.4 38.1 97.1 89 96.9 54.8 38 22 29.9 25.2 17.7
83 18.2 1.0568 64 190.25 72.75 25.3 39.3 103.1 97.8 99.6 58.9 39 23 34.3 29.6 19
84 26.2 1.0377 70 170.75 70 24.5 38.7 101.8 94.9 95 56 36.5 24.1 31.2 27.3 19.2
85 26.1 1.0378 72 168 69.25 24.7 38.5 101.4 99.8 96.2 56.3 36.6 22 29.7 26.3 18
86 25.8 1.0386 67 167 67.5 26 36.5 98.9 89.7 96.2 54.7 37.8 33.7 32.4 27.7 18.2
87 15 1.0648 72 157.75 67.25 24.6 37.7 97.5 88.1 96.9 57.2 37.7 21.8 32.6 28 18.8
88 22.6 1.0462 64 160 65.75 26 36.5 104.3 90.9 93.8 57.8 39.5 23.3 29.2 28.4 18.1
89 8.8 1.08 46 176.75 72.5 23.7 38 97.3 86 99.3 61 38.4 23.8 30.2 29.3 18.8
90 14.3 1.0666 48 176 73 23.3 36.7 96.7 86.5 98.3 60.4 39.9 24.4 28.8 29.6 18.7
91 20.2 1.052 46 177 70 25.4 37.2 99.7 95.6 102.2 58.3 38.2 22.5 29.1 27.7 17.7
92 18.1 1.0573 44 179.75 69.5 26.2 39.2 101.9 93.2 100.6 58.9 39.7 23.1 31.4 28.4 18.8
93 9.2 1.0795 47 165.25 70.5 23.4 37.5 97.2 83.1 95.4 56.9 38.3 22.1 30.1 28.2 18.4
94 24.2 1.0424 46 192.5 71.75 26.3 38 106.6 97.5 100.6 58.9 40.5 24.5 33.3 29.6 19.1
95 9.6 1.0785 47 184.25 74.5 23.4 37.3 99.6 88.8 101.4 57.4 39.6 24.6 30.3 27.9 17.8
96 17.3 1.0991 53 224.5 77.75 26.1 41.1 113.2 99.2 107.5 61.7 42.3 23.2 32.9 30.8 20.4
97 10.1 1.077 38 188.75 73.25 24.8 37.5 99.1 91.6 102.4 60.6 39.4 22.9 31.6 30.1 18.5
98 11.1 1.073 50 162.5 66.5 25.9 38.7 99.4 86.7 96.2 62.1 39.3 23.3 30.6 27.8 18.2
99 17.7 1.0582 46 156.5 68.25 23.7 35.9 95.1 88.2 92.8 54.7 37.3 21.9 31.6 27.5 18.2
100 21.7 1.0484 47 197 72 26.7 40 107.5 94 103.7 62.7 39 22.3 35.3 30.9 18.3
101 20.8 1.0506 49 198.5 73.5 25.9 40.1 106.5 95 101.7 59 39.4 22.3 32.2 31 18.6
102 20.1 1.0524 48 173.75 72 23.6 37 99.1 92 98.3 59.3 38.4 22.4 27.9 26.2 17
103 19.8 1.053 41 172.75 71.25 24 36.3 96.7 89.2 98.3 60 38.4 23.2 31 29.2 18.4
104 21.9 1.048 49 196.75 73.75 25.5 40.7 103.5 95.5 101.6 59.1 39.8 25.4 31 30.3 19.7
105 24.7 1.0412 43 177 69.25 26 39.6 104 98.6 99.5 59.5 36.1 22 30.1 27.2 17.7
106 17.8 1.0578 43 165.5 68.5 24.8 31.1 93.1 87.3 96.6 54.7 39 24.8 31 29.4 18.8
107 19.1 1.0547 43 200.25 73.5 26 38.6 105.2 102.8 103.6 61.2 39.3 23.5 30.5 28.5 18.1
108 18.2 1.0569 52 203.25 74.25 26 42 110 101.6 100.7 55.8 38.7 23.4 35.1 29.6 19.1
109 17.2 1.0593 43 194 75.5 24 38.5 110.1 88.7 102.1 57.5 40 24.8 35.1 30.7 19.2
110 21 1.05 40 168.5 69.25 24.7 34.2 97.8 92.3 100.6 57.5 36.8 22.8 32.1 26 17.3
111 19.5 1.0538 43 170.75 68.5 25.6 37.2 96.3 90.6 99.3 61.9 38 22.3 33.3 28.2 18.1
112 27.1 1.0355 43 183.25 70 26.3 37.1 108 105 103 63.7 40 23.6 33.5 27.8 17.4
113 21.6 1.0486 47 178.25 70 25.6 40.2 99.7 95 98.6 62.3 38.1 23.9 35.3 31.1 19.8
114 20.9 1.0503 42 163 70.25 23.3 35.3 93.5 89.6 99.8 61.5 37.8 21.9 30.7 27.6 17.4
115 25.9 1.0384 48 175.25 71.75 24 38 100.7 92.4 97.5 59.3 38.1 21.8 31.8 27.3 17.5
116 16.7 1.0607 40 158 69.25 23.4 36.3 97 86.6 92.6 55.9 36.3 22.1 29.8 26.3 17.3
117 19.8 1.0529 48 177.25 72.75 23.6 36.8 96 90 99.7 58.8 38.4 22.8 29.9 28 18.1
118 14.1 1.0671 51 179 72 24.3 41 99.2 90 96.4 56.8 38.8 23.3 33.4 29.8 19.5
119 25.1 1.0404 40 191 74 24.6 38.3 95.4 92.4 104.3 64.6 41.1 24.8 33.6 29.5 18.5
120 17.9 1.0575 44 187.5 72.25 25.3 38 101.8 87.5 101 58.5 39.2 24.5 32.1 28.6 18
121 27 1.0358 52 206.5 74.5 26.2 40.8 104.3 99.2 104.1 58.5 39.3 24.6 33.9 31.2 19.5
122 24.6 1.0414 44 185.25 71.5 25.5 39.5 99.2 98.1 101.4 57.1 40.5 23.2 33 29.6 18.4
123 14.8 1.0652 40 160.25 68.75 23.9 36.9 99.3 83.3 97.5 60.5 38.7 22.6 34.4 28 17.6
124 16 1.0623 47 151.5 66.75 23.9 36.9 94 86.1 95.2 58.1 36.5 22.1 30.6 27.5 17.6
125 14 1.0674 50 161 66.5 25.6 37.7 98.9 84.1 94 58.5 36.6 23.5 34.4 29.2 18
126 17.4 1.0587 46 167 67 26.2 36.6 101 89.9 100 60.7 36 21.9 35.6 30.2 17.6
127 26.4 1.0373 42 177.5 68.75 26.4 38.9 98.7 92.1 98.5 60.7 36.8 22.2 33.8 30.3 17.2
128 17.4 1.059 43 152.25 67.75 23.4 37.5 95.9 78 93.2 53.5 35.8 20.8 33.9 28.2 17.4
129 20.4 1.0515 40 192.25 73.25 25.2 39.8 103.9 93.5 99.5 61.7 39 21.8 33.3 29.6 18.1
130 15 1.0648 42 165.25 69.75 23.9 38.3 96.2 87 97.8 57.4 36.9 22.2 31.6 27.8 17.7
131 18 1.0575 49 171.75 71.5 23.7 35.5 97.8 90.1 95.8 57 38.7 23.2 27.5 26.5 17.6
132 22.2 1.0472 40 171.25 70.5 24.3 36.3 94.6 90.3 99.1 60.3 38.5 23 31.2 28.4 17.1
133 23.1 1.0452 47 197 73.25 25.8 37.8 103.6 99.8 103.2 61.2 38.1 22.6 33.5 28.6 17.9
134 25.3 1.0398 50 157 66.75 24.8 37.8 100.4 89.4 92.3 56.1 35.6 20.5 33.6 29.3 17.3
135 23.8 1.0435 41 168.25 69.5 24.5 36.5 98.4 87.2 98.4 56 36.9 23 34 29.8 18.1
136 26.3 1.0374 44 186 69.75 26.8 37.8 104.6 101.1 102.1 58.9 37.9 22.7 30.9 28.8 17.6
137 21.4 1.0491 39 166.75 70.75 23.5 37 92.9 86.1 95.6 58.8 36.1 22.4 32.7 28.3 17.1
138 28.4 1.0325 43 187.75 74 24.1 37.7 97.8 98.6 100.6 63.6 39.2 23.8 34.3 28.4 17.7
139 21.8 1.0481 40 168.25 71.25 23.3 34.3 98.3 88.5 98.3 58.1 38.4 22.5 31.7 27.4 17.6
140 20.1 1.0522 49 212.75 75 26.6 40.8 104.7 106.6 107.7 66.5 42.5 24.5 35.5 29.8 18.7
141 24.3 1.0422 40 176.75 71 24.6 37.4 98.6 93.1 101.6 59.1 39.6 21.6 30.8 27.9 16.6
142 18.1 1.0571 40 173.25 69.5 25.3 36.5 99.5 93 99.3 60.4 38.2 22 32 28.5 17.8
143 22.7 1.0459 52 167 67.75 25.6 37.5 102.7 91 98.9 57.1 36.7 22.3 31.6 27.5 17.9
144 9.9 1.0775 23 159.75 72.25 21.6 35.5 92.1 77.1 93.9 56.1 36.1 22.7 30.5 27.2 18.2
145 10.8 1.0754 23 188.15 77.5 22.1 38 96.6 85.3 102.5 59.1 37.6 23.2 31.8 29.7 18.3
146 14.4 1.0664 24 156 70.75 21.9 35.7 92.7 81.9 95.3 56.4 36.5 22 33.5 28.3 17.3
147 19 1.055 24 208.5 72.75 27.7 39.2 102 99.1 110.1 71.2 43.5 25.2 36.1 30.3 18.7
148 28.6 1.0322 25 206.5 69.75 29.8 40.9 110.9 100.5 106.2 68.4 40.8 24.6 33.3 29.7 18.4
149 6.1 1.0873 25 143.75 72.5 19.3 35.2 92.3 76.5 92.1 51.9 35.7 22 25.8 25.2 16.9
150 24.5 1.0416 26 223 70.25 31.8 40.6 114.1 106.8 113.9 67.6 42.7 24.7 36 30.4 18.4
151 9.9 1.0776 26 152.25 69 22.5 35.4 92.9 77.6 93.5 56.9 35.9 20.4 31.6 29 17.8
152 19.1 1.0542 26 241.75 74.5 30.7 41.8 108.3 102.9 114.4 72.9 43.5 25.1 38.5 33.8 19.6
153 10.6 1.0758 27 146 72.25 19.7 34.1 88.5 72.8 91.1 53.6 36.8 23.8 27.8 26.3 17.4
154 16.5 1.061 27 156.75 67.25 24.4 37.9 94 88.2 95.2 56.8 37.4 22.8 30.6 28.3 17.9
155 20.5 1.051 27 200.25 73.5 26.1 38.2 101.1 100.1 105 62.1 40 24.9 33.7 29.2 19.4
156 17.2 1.0594 28 171.5 75.25 21.6 35.6 92.1 83.5 98.3 57.3 37.8 21.7 32.2 27.7 17.7
157 30.1 1.0287 28 205.75 69 30.4 38.5 105.6 105 106.4 68.6 40 25.2 35.2 30.7 19.1
158 10.5 1.0761 28 182.5 72.25 24.6 37 98.5 90.8 102.5 60.8 38.5 25 31.6 28 18.6
159 12.8 1.0704 30 136.5 68.75 20.3 35.9 88.7 76.6 89.8 50.1 34.8 21.8 27 34.9 16.9
160 22 1.0477 31 177.25 71.5 24.4 36.2 101.1 92.4 99.3 59.4 39 24.6 30.1 28.2 18.2
161 9.9 1.0775 31 151.25 72.25 20.4 35 94 81.2 91.5 52.5 36.6 21 27 26.3 16.5
162 14.8 1.0653 33 196 73 25.9 38.5 103.8 95.6 105.1 61.4 40.6 25 31.3 29.2 19.1
163 13.3 1.069 33 184.25 68.75 24.4 40.7 98.9 92.1 103.5 64 37.3 23.5 33.5 30.6 19.7
164 15.2 1.0644 34 140 70.5 19.8 36 89.2 83.4 89.6 52.4 35.6 20.4 28.3 26.2 16.5
165 26.5 1.037 34 218.75 72 29.7 39.5 111.4 106 108.8 63.8 42 23.4 34 31.2 18.5
166 19 1.0549 35 217 73.75 28.1 40.5 107.5 95.1 104.5 64.8 41.3 25.6 36.4 33.7 19.4
167 21.4 1.0492 35 166.25 68 25.3 38.5 99.1 90.4 95.6 55.5 34.2 21.9 30.2 28.7 17.7
168 20 1.0525 35 224.75 72.25 30.3 43.9 108.2 100.4 106.8 63.3 41.7 24.6 37.2 33.1 19.8
169 34.7 1.018 35 228.25 69.5 33.3 40.4 114.9 115.9 111.9 74.4 40.6 24 36.1 31.8 18.8
170 16.5 1.061 35 172.75 69.5 25.2 37.6 99.1 90.8 98.1 60.1 39.1 23.4 32.5 29.8 17.4
171 4.1 1.0926 35 152.25 67.75 23.4 37 92.2 81.9 92.8 54.7 36.2 22.1 30.4 27.4 17.7
172 1.9 1.0983 35 125.75 65.5 20.6 34 90.8 75 89.2 50 34.8 22 24.8 25.9 16.9
173 20.2 1.0521 35 177.25 71 24.8 38.4 100.5 90.3 98.7 57.8 37.3 22.4 31 28.7 17.7
174 16.8 1.0603 36 176.25 71.5 24.3 38.7 98.2 90.3 99.9 59.2 37.7 21.5 32.4 28.4 17.8
175 24.6 1.0414 36 226.75 71.75 31 41.5 115.3 108.8 114.4 69.2 42.4 24 35.4 21 20.1
176 10.4 1.0763 37 145.25 69.25 21.3 36 96.8 79.4 89.2 50.3 34.8 22.2 31 26.9 16.9
177 13.4 1.0689 37 151 67 23.7 35.3 92.6 83.2 96.4 60 38.1 22 31.5 26.6 16.7
178 28.8 1.0316 37 241.25 71.5 33.2 42.1 119.2 110.3 113.9 69.8 42.6 24.8 34.4 29.5 18.4
179 22 1.0477 38 187.25 69.25 27.5 38 102.7 92.7 101.9 64.7 39.5 24.7 34.8 30.3 18.1
180 16.8 1.0603 39 234.75 74.5 29.8 42.8 109.5 104.5 109.9 69.5 43.1 25.8 39.1 32.5 19.9
181 25.8 1.0387 39 219.25 74.25 28 40 108.5 104.6 109.8 68.1 42.8 24.1 35.6 29 19
182 0 1.1089 40 118.5 68 18.1 33.8 79.3 69.4 85 47.2 33.5 20.2 27.7 24.6 16.5
183 11.9 1.0725 40 145.75 67.25 22.7 35.5 95.5 83.6 91.6 54.1 36.2 21.8 31.4 28.3 17.2
184 12.4 1.0713 40 159.25 69.75 23 35.3 92.3 86.8 96.1 58 39.4 22.7 30 26.4 17.4
185 17.4 1.0587 40 170.5 74.25 21.8 37.7 98.9 90.4 95.5 55.4 38.9 22.4 30.5 28.9 17.7
186 9.2 1.0794 40 167.5 71.5 23.1 39.4 89.5 83.7 98.1 57.3 39.7 22.6 32.9 29.3 18.2
187 23 1.0453 41 232.75 74.25 29.7 41.9 117.5 109.3 108.8 67.7 41.3 24.7 37.2 31.8 20
188 20.1 1.0524 41 210.5 72 28.6 38.5 107.4 98.9 104.1 63.5 39.8 23.5 36.4 30.4 19.1
189 20.2 1.052 41 202.25 72.5 27 40.8 109.2 98 101.8 62.8 41.3 24.8 36.6 32.4 18.8
190 23.8 1.0434 41 185 68.25 28 38 103.4 101.2 103.1 61.5 40.4 22.9 33.4 29.2 18.5
191 11.8 1.0728 41 153 69.25 22.5 36.4 91.4 80.6 92.3 54.3 36.3 21.8 29.6 27.3 17.9
192 36.5 1.014 42 244.25 76 29.8 41.8 115.2 113.7 112.4 68.5 45 25.5 37.1 31.2 19.9
193 16 1.0624 42 193.5 70.5 27.4 40.7 104.9 94.1 102.7 60.6 38.6 24.7 34 30.1 18.7
194 24 1.0429 42 224.75 74.75 28.3 38.5 106.7 105.7 111.8 65.3 43.3 26 33.7 29.9 18.5
195 22.3 1.047 42 162.75 72.75 21.6 35.4 92.2 85.6 96.5 60.2 38.9 22.4 31.7 27.1 17.1
196 24.8 1.0411 42 180 68.25 27.2 38.5 101.6 96.6 100.6 61.1 38.4 24.1 32.9 29.8 18.8
197 21.5 1.0488 42 156.25 69 23.1 35.5 97.8 86 96.2 57.7 38.6 24 31.2 27.3 17.4
198 17.6 1.0583 42 168 71.5 23.1 36.5 92 89.7 101 62.3 38 22.3 30.8 27.8 16.9
199 7.3 1.0841 42 167.25 72.75 22.3 37.6 94 78 99 57.5 40 22.5 30.6 30 18.5
200 22.6 1.0462 43 170.75 67.5 26.4 37.4 103.7 89.7 94.2 58.5 39 24.1 33.8 28.8 18.8
201 12.5 1.0709 43 178.25 70.25 25.4 37.8 102.7 89.2 99.2 60.2 39.2 23.8 31.7 28.4 18.6
202 21.7 1.0484 43 150 69.25 22 35.2 91.1 85.7 96.9 55.5 35.7 22 29.4 26.6 17.4
203 27.7 1.034 43 200.5 71.5 27.6 37.9 107.2 103.1 105.5 68.8 38.3 23.7 32.1 28.9 18.7
204 6.8 1.0854 44 184 74 23.7 37.9 100.8 89.1 102.6 60.6 39 24 32.9 29.2 18.4
205 33.4 1.0209 44 223 69.75 32.3 40.9 121.6 113.9 107.1 63.5 40.3 21.8 34.8 30.7 17.4
206 16.6 1.061 44 208.75 73 27.6 41.9 105.6 96.3 102 63.3 39.8 24.1 37.3 23.1 19.4
207 31.7 1.025 44 166 65.5 27.2 39.1 100.6 93.9 100.1 58.9 37.6 21.4 33.1 29.5 17.3
208 31.5 1.0254 47 195 72.5 26.1 40.2 102.7 101.3 101.7 60.7 39.4 23.3 36.7 31.6 18.4
209 10.1 1.0771 47 160.5 70.25 22.9 36 99.8 83.9 91.8 53 36.2 22.5 31.4 27.5 17.7
210 11.3 1.0742 47 159.75 70.75 22.5 34.5 92.9 84.4 94 56 38.2 22.6 29 26.2 17.6
211 7.8 1.0829 49 140.5 68 21.4 35.8 91.2 79.4 89 51.1 35 21.7 30.9 28.8 17.4
212 26.4 1.0373 49 216.25 74.5 27.4 40.2 115.6 104 109 63.7 40.3 23.2 36.8 31 18.9
213 19.3 1.0543 49 168.25 71.75 23 38.3 98.3 89.7 99.1 56.3 38.8 23 29.5 27.9 18.6
214 18.5 1.0561 50 194.75 70.75 27.4 39 103.7 97.6 104.2 60 40.9 25.5 32.7 30 19
215 19.3 1.0543 50 172.75 73 22.8 37.4 98.7 87.6 96.1 57.1 38.1 21.8 28.6 26.7 18
216 45.1 0.995 51 219 64 37.6 41.2 119.8 122.1 112.8 62.5 36.9 23.6 34.7 29.1 18.4
217 13.8 1.0678 51 149.25 69.75 21.6 34.8 92.8 81.1 96.3 53.8 36.5 21.5 31.3 26.3 17.8
218 8.2 1.0819 51 154.5 70 22.2 36.9 93.3 81.5 94.4 54.7 39 22.6 27.5 25.9 18.6
219 23.9 1.0433 52 199.25 71.75 27.2 39.4 106.8 100 105 63.9 39.2 22.9 35.7 30.4 19.2
220 15.1 1.0646 53 154.5 69.25 22.7 37.6 93.9 88.7 94.5 53.7 36.2 22 28.5 25.7 17.1
221 12.7 1.0706 54 153.25 70.5 24.5 38.5 99 91.8 96.2 57.7 38.1 23.9 31.4 29.9 18.9
222 25.3 1.0399 54 230 72.25 31 42.5 119.9 110.4 105.5 64.2 42.7 27 38.4 32 19.6
223 11.9 1.0726 54 161.75 67.5 25 37.4 94.2 87.6 95.6 59.7 40.2 23.4 27.9 27 17.8
224 6.1 1.0874 55 142.25 67.25 22.2 35.2 92.7 82.8 91.9 54.4 35.2 22.5 29.4 26.8 17
225 11.3 1.074 55 179.75 68.75 26.8 41.1 106.9 95.3 98.2 57.4 37.1 21.8 34.1 31.1 19.2
226 12.8 1.0703 55 126.5 66.75 20 33.4 88.8 78.2 87.5 50.8 33 19.7 25.3 22 15.8
227 14.9 1.065 55 169.5 68.25 25.6 37.2 101.7 91.1 97.1 56.6 38.5 22.6 33.4 29.3 18.8
228 24.5 1.0418 55 198.5 74.25 25.3 38.3 105.3 96.7 106.6 64 42.6 23.4 33.2 30 18.4
229 15 1.0647 56 174.5 69.5 25.4 38.1 104 89.4 98.4 58.4 37.4 22.5 34.6 30.1 18.8
230 16.9 1.0601 56 167.75 68.5 25.2 37.4 98.6 93 97 55.4 38.8 23.2 32.4 29.7 19
231 11.1 1.0745 57 147.75 65.75 24.1 35.2 99.6 86.4 90.1 53 35 21.3 31.7 27.3 16.9
232 16.1 1.062 57 182.25 71.75 24.9 39.4 103.4 96.7 100.7 59.3 38.6 22.8 31.8 29.1 19
233 15.5 1.0636 58 175.5 71.5 24.2 38 100.2 88.1 97.8 57.1 38.9 23.6 30.9 29.6 18
234 25.9 1.0384 58 161.75 67.25 25.2 35.1 94.9 94.9 100.2 56.8 35.9 21 27.8 26.1 17.6
235 25.5 1.0403 60 157.75 67.5 24.1 40.4 97.2 93.3 94 54.3 35.7 21 31.3 28.7 18.3
236 18.4 1.0563 62 168.75 67.5 26.1 38.3 104.7 95.6 93.7 54.4 37.1 22.7 30.3 26.3 18.3
237 24 1.0424 62 191.5 72.25 25.8 40.6 104 98.2 101.1 59.3 40.3 23 32.6 28.5 19
238 26.4 1.0372 63 219.15 69.5 31.9 40.2 117.6 113.8 111.8 63.4 41.1 22.3 35.1 29.6 18.5
239 12.7 1.0705 64 155.25 69.5 22.6 37.9 95.8 82.8 94.5 61.2 39.1 22.3 29.8 28.9 18.3
240 28.8 1.0316 65 189.75 65.75 30.9 40.8 106.4 100.5 100.5 59.2 38.1 24 35.9 30.5 19.1
241 17 1.0599 65 127.5 65.75 20.8 34.7 93 79.7 87.6 50.7 33.4 20.1 28.5 24.8 16.5
242 33.6 1.0207 65 224.5 68.25 33.9 38.8 119.6 118 114.3 61.3 42.1 23.4 34.9 30.1 19.4
243 29.3 1.0304 66 234.25 72 31.8 41.4 119.7 109 109.1 63.7 42.4 24.6 35.6 30.7 19.5
244 31.4 1.0256 67 227.75 72.75 30.3 41.3 115.8 113.4 109.8 65.6 46 25.4 35.3 29.8 19.5
245 28.1 1.0334 67 199.5 68.5 29.9 40.7 118.3 106.1 101.6 58.2 38.8 24.1 32.1 29.3 18.5
246 15.3 1.0641 68 155.5 69.25 22.8 36.3 97.4 84.3 94.4 54.3 37.5 22.6 29.2 27.3 18.5
247 29.1 1.0308 69 215.5 70.5 30.5 40.8 113.7 107.6 110 63.3 44 22.6 37.5 32.6 18.8
248 11.5 1.0736 70 134.25 67 21.1 34.9 89.2 83.6 88.8 49.6 34.8 21.5 25.6 25.7 18.5
249 32.3 1.0236 72 201 69.75 29.1 40.9 108.5 105 104.5 59.6 40.8 23.2 35.2 28.6 20.1
250 28.3 1.0328 72 186.75 66 30.2 38.9 111.1 111.5 101.7 60.3 37.3 21.5 31.3 27.2 18
251 25.3 1.0399 72 190.75 70.5 27 38.9 108.3 101.3 97.8 56 41.6 22.7 30.5 29.4 19.8
252 30.7 1.0271 74 207.5 70 29.8 40.8 112.4 108.5 107.1 59.3 42.2 24.6 33.7 30 20.9
I believe the best way is with ggplot. It becomes a standard grouped bar plot.
library(ggplot2)
ggplot(avgweightpercat, aes(htcat, weight, fill = bodycat)) +
geom_col(position = "dodge")
Aggregate data from the text file.
The aggregated data can be created from the posted file with the following simpler code.
It uses cut with the appropriate labels and intervals end points to create the two factors' levels.
bodydata$bodycat <- cut(bodydata$bodyfat,
breaks = c(0, 14, 25, Inf),
labels = c("Athlete", "Average", "Obese"),
include.lowest = TRUE, right = FALSE)
bodydata$htcat <- cut(bodydata$height,
breaks = c(29.50, 68.25, 70.00, 72.25, 77.75),
labels = c("short", "below average", "above average", "tall"),
include.lowest = TRUE, right = FALSE)
avgweightpercat <- aggregate(weight ~ bodycat + htcat,
data = bodydata, FUN = mean)
Data in dput format.
avgweightpercat <-
structure(list(bodycat = structure(c(1L, 2L, 3L, 1L, 2L, 3L,
1L, 2L, 3L, 1L, 2L, 3L), .Label = c("Athlete", "Average", "Obese"
), class = "factor"), htcat = structure(c(1L, 1L, 1L, 2L, 2L,
2L, 3L, 3L, 3L, 4L, 4L, 4L), .Label = c("short", "below average",
"above average", "tall"), class = "factor"), weight = c(138.886363636364,
161.654761904762, 178.683333333333, 154.333333333333, 170.172413793103,
205.243333333333, 160.979166666667, 180.99358974359, 202.823529411765,
175.075, 199.863636363636, 228.679166666667)), row.names = c(NA,
-12L), class = "data.frame")
First, I read in the bodyfat.csv data file and generate a variable "bodycat" to categorize body fat into the three categories athlete, average, or obese. (Athlete, less than 14%, Average, 14-25%, Obese, greater than 25%)
bodycat <- read.csv("bodyfat.csv",header=T)
bodytype <- c()
bodytype[bodycat$bodyfat<14]<-"Athlete"
bodytype[bodycat$bodyfat>=14 & bodycat$bodyfat<25]<-"Average"
bodytype[bodycat$bodyfat>=25]<-"Obese"
bodycat <-cbind(bodycat,bodytype)
remove(bodytype)
Second, I want to create a violin plot of weight separated by bodycat. Trying to figure out
Are the weights evenly distributed within a range for all categories?
Do athletes tend to be within a certain weight range?
library(lattice)
bwplot(weight~bodycat, data = bodycat, panel = panel.violin,
xlab = "weight", ylab = "bodycat")
I only got an error in R studio, what's wrong with my code? Or I can only create "violin plot of weight separated by bodycat" by manully create every violin plot of weight separated by "each column" in this csv?
like:
bwplot(weight~age, data = bodycat, panel = panel.violin,
xlab = "weight", ylab = "bodycat")
bodyfat.csv in plain text
id bodyfat density age weight height adiposity neck chest abdomen hip thigh knee ankle bicep forearm wrist
1 12.6 1.0708 23 154.25 67.75 23.7 36.2 93.1 85.2 94.5 59 37.3 21.9 32 27.4 17.1
2 6.9 1.0853 22 173.25 72.25 23.4 38.5 93.6 83 98.7 58.7 37.3 23.4 30.5 28.9 18.2
3 24.6 1.0414 22 154 66.25 24.7 34 95.8 87.9 99.2 59.6 38.9 24 28.8 25.2 16.6
4 10.9 1.0751 26 184.75 72.25 24.9 37.4 101.8 86.4 101.2 60.1 37.3 22.8 32.4 29.4 18.2
5 27.8 1.034 24 184.25 71.25 25.6 34.4 97.3 100 101.9 63.2 42.2 24 32.2 27.7 17.7
6 20.6 1.0502 24 210.25 74.75 26.5 39 104.5 94.4 107.8 66 42 25.6 35.7 30.6 18.8
7 19 1.0549 26 181 69.75 26.2 36.4 105.1 90.7 100.3 58.4 38.3 22.9 31.9 27.8 17.7
8 12.8 1.0704 25 176 72.5 23.6 37.8 99.6 88.5 97.1 60 39.4 23.2 30.5 29 18.8
9 5.1 1.09 25 191 74 24.6 38.1 100.9 82.5 99.9 62.9 38.3 23.8 35.9 31.1 18.2
10 12 1.0722 23 198.25 73.5 25.8 42.1 99.6 88.6 104.1 63.1 41.7 25 35.6 30 19.2
11 7.5 1.083 26 186.25 74.5 23.6 38.5 101.5 83.6 98.2 59.7 39.7 25.2 32.8 29.4 18.5
12 8.5 1.0812 27 216 76 26.3 39.4 103.6 90.9 107.7 66.2 39.2 25.9 37.2 30.2 19
13 20.5 1.0513 32 180.5 69.5 26.3 38.4 102 91.6 103.9 63.4 38.3 21.5 32.5 28.6 17.7
14 20.8 1.0505 30 205.25 71.25 28.5 39.4 104.1 101.8 108.6 66 41.5 23.7 36.9 31.6 18.8
15 21.7 1.0484 35 187.75 69.5 27.4 40.5 101.3 96.4 100.1 69 39 23.1 36.1 30.5 18.2
16 20.5 1.0512 35 162.75 66 26.3 36.4 99.1 92.8 99.2 63.1 38.7 21.7 31.1 26.4 16.9
17 28.1 1.0333 34 195.75 71 27.3 38.9 101.9 96.4 105.2 64.8 40.8 23.1 36.2 30.8 17.3
18 22.4 1.0468 32 209.25 71 29.2 42.1 107.6 97.5 107 66.9 40 24.4 38.2 31.6 19.3
19 16.1 1.0622 28 183.75 67.75 28.2 38 106.8 89.6 102.4 64.2 38.7 22.9 37.2 30.5 18.5
20 16.5 1.061 33 211.75 73.5 27.6 40 106.2 100.5 109 65.8 40.6 24 37.1 30.1 18.2
21 19 1.0551 28 179 68 27.3 39.1 103.3 95.9 104.9 63.5 38 22.1 32.5 30.3 18.4
22 15.3 1.064 28 200.5 69.75 29.1 41.3 111.4 98.8 104.8 63.4 40.6 24.6 33 32.8 19.9
23 15.7 1.0631 31 140.25 68.25 21.2 33.9 86 76.4 94.6 57.4 35.3 22.2 27.9 25.9 16.7
24 17.6 1.0584 32 148.75 70 21.4 35.5 86.7 80 93.4 54.9 36.2 22.1 29.8 26.7 17.1
25 14.2 1.0668 28 151.25 67.75 23.2 34.5 90.2 76.3 95.8 58.4 35.5 22.9 31.1 28 17.6
26 4.6 1.0911 27 159.25 71.5 21.9 35.7 89.6 79.7 96.5 55 36.7 22.5 29.9 28.2 17.7
27 8.5 1.0811 34 131.5 67.5 20.3 36.2 88.6 74.6 85.3 51.7 34.7 21.4 28.7 27 16.5
28 22.4 1.0468 31 148 67.5 22.9 38.8 97.4 88.7 94.7 57.5 36 21 29.2 26.6 17
29 4.7 1.091 27 133.25 64.75 22.4 36.4 93.5 73.9 88.5 50.1 34.5 21.3 30.5 27.9 17.2
30 9.4 1.079 29 160.75 69 23.8 36.7 97.4 83.5 98.7 58.9 35.3 22.6 30.1 26.7 17.6
31 12.3 1.0716 32 182 73.75 23.6 38.7 100.5 88.7 99.8 57.5 38.7 33.9 32.5 27.7 18.4
32 6.5 1.0862 29 160.25 71.25 22.2 37.3 93.5 84.5 100.6 58.5 38.8 21.5 30.1 26.4 17.9
33 13.4 1.0719 27 168 71.25 23.3 38.1 93 79.1 94.5 57.3 36.2 24.5 29 30 18.8
34 20.9 1.0502 41 218.5 71 30.5 39.8 111.7 100.5 108.3 67.1 44.2 25.2 37.5 31.5 18.7
35 31.1 1.0263 41 247.25 73.5 32.2 42.1 117 115.6 116.1 71.2 43.3 26.3 37.3 31.7 19.7
36 38.2 1.0101 49 191.75 65 32 38.4 118.5 113.1 113.8 61.9 38.3 21.9 32 29.8 17
37 23.6 1.0438 40 202.25 70 29.1 38.5 106.5 100.9 106.2 63.5 39.9 22.6 35.1 30.6 19
38 27.5 1.0346 50 196.75 68.25 29.7 42.1 105.6 98.8 104.8 66 41.5 24.7 33.2 30.5 19.4
39 33.8 1.0202 46 363.15 72.25 48.9 51.2 136.2 148.1 147.7 87.3 49.1 29.6 45 29 21.4
40 31.3 1.0258 50 203 67 31.8 40.2 114.8 108.1 102.5 61.3 41.1 24.7 34.1 31 18.3
41 33.1 1.0217 45 262.75 68.75 39.1 43.2 128.3 126.2 125.6 72.5 39.6 26.6 36.4 32.7 21.4
42 31.7 1.025 44 205 29.5 29.9 36.6 106 104.3 115.5 70.6 42.5 23.7 33.6 28.7 17.4
43 30.4 1.0279 48 217 70 31.2 37.3 113.3 111.2 114.1 67.7 40.9 25 36.7 29.8 18.4
44 30.8 1.0269 41 212 71.5 29.2 41.5 106.6 104.3 106 65 40.2 23 35.8 31.5 18.8
45 8.4 1.0814 39 125.25 68 19.1 31.5 85.1 76 88.2 50 34.7 21 26.1 23.1 16.1
46 14.1 1.067 43 164.25 73.25 21.3 35.7 96.6 81.5 97.2 58.4 38.2 23.4 29.7 27.4 18.3
47 11.2 1.0742 40 133.5 67.5 20.6 33.6 88.2 73.7 88.5 53.3 34.5 22.5 27.9 26.2 17.3
48 6.4 1.0665 39 148.5 71.25 20.6 34.6 89.8 79.5 92.7 52.7 37.5 21.9 28.8 26.8 17.9
49 13.4 1.0678 45 135.75 68.5 20.4 32.8 92.3 83.4 90.4 52 35.8 20.6 28.8 25.5 16.3
50 5 1.0903 47 127.5 66.75 20.2 34 83.4 70.4 87.2 50.6 34.4 21.9 26.8 25.8 16.8
51 10.7 1.0756 47 158.25 72.25 21.3 34.9 90.2 86.7 98.3 52.6 37.2 22.4 26 25.8 17.3
52 7.4 1.084 40 139.25 69 20.6 34.3 89.2 77.9 91 51.4 34.9 21 26.7 26.1 17.2
53 8.7 1.0807 51 137.25 67.75 21.1 36.5 89.7 82 89.1 49.3 33.7 21.4 29.6 26 16.9
54 7.1 1.0848 49 152.75 73.5 19.9 35.1 93.3 79.6 91.6 52.6 37.6 22.6 38.5 27.4 18.5
55 4.9 1.0906 42 136.25 67.5 21.1 37.8 87.6 77.6 88.6 51.9 34.9 22.5 27.7 27.5 18.5
56 22.2 1.0473 54 198 72 26.9 39.9 107.6 100 99.6 57.2 38 22 35.9 30.2 18.9
57 20.1 1.0524 58 181.5 68 27.6 39.1 100 99.8 102.5 62.1 39.6 22.5 33.1 28.3 18.5
58 27.1 1.0356 62 201.25 69.5 29.3 40.5 111.5 104.2 105.8 61.8 39.8 22.7 37.7 30.9 19.2
59 30.4 1.028 54 202.5 70.75 28.4 40.5 115.4 105.3 97 59.1 38 22.5 31.6 28.8 18.2
60 24 1.043 61 179.75 65.75 29.2 38.4 104.8 98.3 99.6 60.6 37.7 22.9 34.5 29.6 18.5
61 25.4 1.0396 62 216 73.25 28.2 41.4 112.3 104.8 103.1 61.6 40.9 23.1 36.2 31.8 20.2
62 28.8 1.0317 56 178.75 68.5 26.8 35.6 102.9 94.7 100.8 60.9 38 22.1 32.5 29.8 18.3
63 29.6 1.0298 54 193.25 70.25 27.6 38 107.6 102.4 99.4 61 39.4 23.6 32.7 29.9 19.1
64 25.1 1.0403 61 178 67 27.9 37.4 105.3 99.7 99.7 60.8 40.1 22.7 33.6 29 18.8
65 31 1.0264 57 205.5 70 29.5 40.1 105.3 105.5 108.3 65 41.2 24.7 35.3 31.1 18.4
66 28.9 1.0313 55 183.5 67.5 28.3 40.9 103 100.3 104.2 64.8 40.2 22.7 34.8 30.1 18.7
67 21.1 1.0499 54 151.5 70.75 21.3 35.6 90 83.9 93.9 55 36.1 21.7 29.6 27.4 17.4
68 14 1.0673 55 154.75 71.5 21.3 36.9 95.4 86.6 91.8 54.3 35.4 21.5 32.8 27.4 18.7
69 7.1 1.0847 54 155.25 69.25 22.8 37.5 89.3 78.4 96.1 56 37.4 22.4 32.6 28.1 18.1
70 13.2 1.0693 55 156.75 71.5 21.6 36.3 94.4 84.6 94.3 51.2 37.4 21.6 27.3 27.1 17.3
71 23.7 1.0439 62 167.5 71.5 23.1 35.5 97.6 91.5 98.5 56.6 38.6 22.4 31.5 27.3 18.6
72 9.4 1.0788 55 146.75 68.75 21.9 38.7 88.5 82.8 95.5 58.9 37.6 21.6 30.3 27.3 18.3
73 9.1 1.0796 56 160.75 73.75 20.8 36.4 93.6 82.9 96.3 52.9 37.5 23.1 29.7 27.3 18.2
74 13.7 1.068 55 125 64 21.5 33.2 87.7 76 88.6 50.9 35.4 19.1 29.3 25.7 16.9
75 12 1.072 61 143 65.75 23.3 36.5 93.4 83.3 93 55.5 35.2 20.9 29.4 27 16.8
76 18.3 1.0666 61 148.25 67.5 22.9 36 91.6 81.8 94.8 54.5 37 21.4 29.3 27 18.3
77 9.2 1.079 57 162.5 69.5 23.7 38.7 91.6 78.8 94.3 56.7 39.7 24.2 30.2 29.2 18.1
78 21.7 1.0483 69 177.75 68.5 26.7 38.7 102 95 98.3 55 38.3 21.8 30.8 25.7 18.8
79 21.1 1.0498 81 161.25 70.25 23 37.8 96.4 95.4 99.3 53.5 37.5 21.5 31.4 26.8 18.3
80 18.6 1.056 66 171.25 69.25 25.1 37.4 102.7 98.6 100.2 56.5 39.3 22.7 30.3 28.7 19
81 30.2 1.0283 67 163.75 67.75 25.1 38.4 97.7 95.8 97.1 54.8 38.2 23.7 29.4 27.2 19
82 26 1.0382 64 150.25 67.25 23.4 38.1 97.1 89 96.9 54.8 38 22 29.9 25.2 17.7
83 18.2 1.0568 64 190.25 72.75 25.3 39.3 103.1 97.8 99.6 58.9 39 23 34.3 29.6 19
84 26.2 1.0377 70 170.75 70 24.5 38.7 101.8 94.9 95 56 36.5 24.1 31.2 27.3 19.2
85 26.1 1.0378 72 168 69.25 24.7 38.5 101.4 99.8 96.2 56.3 36.6 22 29.7 26.3 18
86 25.8 1.0386 67 167 67.5 26 36.5 98.9 89.7 96.2 54.7 37.8 33.7 32.4 27.7 18.2
87 15 1.0648 72 157.75 67.25 24.6 37.7 97.5 88.1 96.9 57.2 37.7 21.8 32.6 28 18.8
88 22.6 1.0462 64 160 65.75 26 36.5 104.3 90.9 93.8 57.8 39.5 23.3 29.2 28.4 18.1
89 8.8 1.08 46 176.75 72.5 23.7 38 97.3 86 99.3 61 38.4 23.8 30.2 29.3 18.8
90 14.3 1.0666 48 176 73 23.3 36.7 96.7 86.5 98.3 60.4 39.9 24.4 28.8 29.6 18.7
91 20.2 1.052 46 177 70 25.4 37.2 99.7 95.6 102.2 58.3 38.2 22.5 29.1 27.7 17.7
92 18.1 1.0573 44 179.75 69.5 26.2 39.2 101.9 93.2 100.6 58.9 39.7 23.1 31.4 28.4 18.8
93 9.2 1.0795 47 165.25 70.5 23.4 37.5 97.2 83.1 95.4 56.9 38.3 22.1 30.1 28.2 18.4
94 24.2 1.0424 46 192.5 71.75 26.3 38 106.6 97.5 100.6 58.9 40.5 24.5 33.3 29.6 19.1
95 9.6 1.0785 47 184.25 74.5 23.4 37.3 99.6 88.8 101.4 57.4 39.6 24.6 30.3 27.9 17.8
96 17.3 1.0991 53 224.5 77.75 26.1 41.1 113.2 99.2 107.5 61.7 42.3 23.2 32.9 30.8 20.4
97 10.1 1.077 38 188.75 73.25 24.8 37.5 99.1 91.6 102.4 60.6 39.4 22.9 31.6 30.1 18.5
98 11.1 1.073 50 162.5 66.5 25.9 38.7 99.4 86.7 96.2 62.1 39.3 23.3 30.6 27.8 18.2
99 17.7 1.0582 46 156.5 68.25 23.7 35.9 95.1 88.2 92.8 54.7 37.3 21.9 31.6 27.5 18.2
100 21.7 1.0484 47 197 72 26.7 40 107.5 94 103.7 62.7 39 22.3 35.3 30.9 18.3
101 20.8 1.0506 49 198.5 73.5 25.9 40.1 106.5 95 101.7 59 39.4 22.3 32.2 31 18.6
102 20.1 1.0524 48 173.75 72 23.6 37 99.1 92 98.3 59.3 38.4 22.4 27.9 26.2 17
103 19.8 1.053 41 172.75 71.25 24 36.3 96.7 89.2 98.3 60 38.4 23.2 31 29.2 18.4
104 21.9 1.048 49 196.75 73.75 25.5 40.7 103.5 95.5 101.6 59.1 39.8 25.4 31 30.3 19.7
105 24.7 1.0412 43 177 69.25 26 39.6 104 98.6 99.5 59.5 36.1 22 30.1 27.2 17.7
106 17.8 1.0578 43 165.5 68.5 24.8 31.1 93.1 87.3 96.6 54.7 39 24.8 31 29.4 18.8
107 19.1 1.0547 43 200.25 73.5 26 38.6 105.2 102.8 103.6 61.2 39.3 23.5 30.5 28.5 18.1
108 18.2 1.0569 52 203.25 74.25 26 42 110 101.6 100.7 55.8 38.7 23.4 35.1 29.6 19.1
109 17.2 1.0593 43 194 75.5 24 38.5 110.1 88.7 102.1 57.5 40 24.8 35.1 30.7 19.2
110 21 1.05 40 168.5 69.25 24.7 34.2 97.8 92.3 100.6 57.5 36.8 22.8 32.1 26 17.3
111 19.5 1.0538 43 170.75 68.5 25.6 37.2 96.3 90.6 99.3 61.9 38 22.3 33.3 28.2 18.1
112 27.1 1.0355 43 183.25 70 26.3 37.1 108 105 103 63.7 40 23.6 33.5 27.8 17.4
113 21.6 1.0486 47 178.25 70 25.6 40.2 99.7 95 98.6 62.3 38.1 23.9 35.3 31.1 19.8
114 20.9 1.0503 42 163 70.25 23.3 35.3 93.5 89.6 99.8 61.5 37.8 21.9 30.7 27.6 17.4
115 25.9 1.0384 48 175.25 71.75 24 38 100.7 92.4 97.5 59.3 38.1 21.8 31.8 27.3 17.5
116 16.7 1.0607 40 158 69.25 23.4 36.3 97 86.6 92.6 55.9 36.3 22.1 29.8 26.3 17.3
117 19.8 1.0529 48 177.25 72.75 23.6 36.8 96 90 99.7 58.8 38.4 22.8 29.9 28 18.1
118 14.1 1.0671 51 179 72 24.3 41 99.2 90 96.4 56.8 38.8 23.3 33.4 29.8 19.5
119 25.1 1.0404 40 191 74 24.6 38.3 95.4 92.4 104.3 64.6 41.1 24.8 33.6 29.5 18.5
120 17.9 1.0575 44 187.5 72.25 25.3 38 101.8 87.5 101 58.5 39.2 24.5 32.1 28.6 18
121 27 1.0358 52 206.5 74.5 26.2 40.8 104.3 99.2 104.1 58.5 39.3 24.6 33.9 31.2 19.5
122 24.6 1.0414 44 185.25 71.5 25.5 39.5 99.2 98.1 101.4 57.1 40.5 23.2 33 29.6 18.4
123 14.8 1.0652 40 160.25 68.75 23.9 36.9 99.3 83.3 97.5 60.5 38.7 22.6 34.4 28 17.6
124 16 1.0623 47 151.5 66.75 23.9 36.9 94 86.1 95.2 58.1 36.5 22.1 30.6 27.5 17.6
125 14 1.0674 50 161 66.5 25.6 37.7 98.9 84.1 94 58.5 36.6 23.5 34.4 29.2 18
126 17.4 1.0587 46 167 67 26.2 36.6 101 89.9 100 60.7 36 21.9 35.6 30.2 17.6
127 26.4 1.0373 42 177.5 68.75 26.4 38.9 98.7 92.1 98.5 60.7 36.8 22.2 33.8 30.3 17.2
128 17.4 1.059 43 152.25 67.75 23.4 37.5 95.9 78 93.2 53.5 35.8 20.8 33.9 28.2 17.4
129 20.4 1.0515 40 192.25 73.25 25.2 39.8 103.9 93.5 99.5 61.7 39 21.8 33.3 29.6 18.1
130 15 1.0648 42 165.25 69.75 23.9 38.3 96.2 87 97.8 57.4 36.9 22.2 31.6 27.8 17.7
131 18 1.0575 49 171.75 71.5 23.7 35.5 97.8 90.1 95.8 57 38.7 23.2 27.5 26.5 17.6
132 22.2 1.0472 40 171.25 70.5 24.3 36.3 94.6 90.3 99.1 60.3 38.5 23 31.2 28.4 17.1
133 23.1 1.0452 47 197 73.25 25.8 37.8 103.6 99.8 103.2 61.2 38.1 22.6 33.5 28.6 17.9
134 25.3 1.0398 50 157 66.75 24.8 37.8 100.4 89.4 92.3 56.1 35.6 20.5 33.6 29.3 17.3
135 23.8 1.0435 41 168.25 69.5 24.5 36.5 98.4 87.2 98.4 56 36.9 23 34 29.8 18.1
136 26.3 1.0374 44 186 69.75 26.8 37.8 104.6 101.1 102.1 58.9 37.9 22.7 30.9 28.8 17.6
137 21.4 1.0491 39 166.75 70.75 23.5 37 92.9 86.1 95.6 58.8 36.1 22.4 32.7 28.3 17.1
138 28.4 1.0325 43 187.75 74 24.1 37.7 97.8 98.6 100.6 63.6 39.2 23.8 34.3 28.4 17.7
139 21.8 1.0481 40 168.25 71.25 23.3 34.3 98.3 88.5 98.3 58.1 38.4 22.5 31.7 27.4 17.6
140 20.1 1.0522 49 212.75 75 26.6 40.8 104.7 106.6 107.7 66.5 42.5 24.5 35.5 29.8 18.7
141 24.3 1.0422 40 176.75 71 24.6 37.4 98.6 93.1 101.6 59.1 39.6 21.6 30.8 27.9 16.6
142 18.1 1.0571 40 173.25 69.5 25.3 36.5 99.5 93 99.3 60.4 38.2 22 32 28.5 17.8
143 22.7 1.0459 52 167 67.75 25.6 37.5 102.7 91 98.9 57.1 36.7 22.3 31.6 27.5 17.9
144 9.9 1.0775 23 159.75 72.25 21.6 35.5 92.1 77.1 93.9 56.1 36.1 22.7 30.5 27.2 18.2
145 10.8 1.0754 23 188.15 77.5 22.1 38 96.6 85.3 102.5 59.1 37.6 23.2 31.8 29.7 18.3
146 14.4 1.0664 24 156 70.75 21.9 35.7 92.7 81.9 95.3 56.4 36.5 22 33.5 28.3 17.3
147 19 1.055 24 208.5 72.75 27.7 39.2 102 99.1 110.1 71.2 43.5 25.2 36.1 30.3 18.7
148 28.6 1.0322 25 206.5 69.75 29.8 40.9 110.9 100.5 106.2 68.4 40.8 24.6 33.3 29.7 18.4
149 6.1 1.0873 25 143.75 72.5 19.3 35.2 92.3 76.5 92.1 51.9 35.7 22 25.8 25.2 16.9
150 24.5 1.0416 26 223 70.25 31.8 40.6 114.1 106.8 113.9 67.6 42.7 24.7 36 30.4 18.4
151 9.9 1.0776 26 152.25 69 22.5 35.4 92.9 77.6 93.5 56.9 35.9 20.4 31.6 29 17.8
152 19.1 1.0542 26 241.75 74.5 30.7 41.8 108.3 102.9 114.4 72.9 43.5 25.1 38.5 33.8 19.6
153 10.6 1.0758 27 146 72.25 19.7 34.1 88.5 72.8 91.1 53.6 36.8 23.8 27.8 26.3 17.4
154 16.5 1.061 27 156.75 67.25 24.4 37.9 94 88.2 95.2 56.8 37.4 22.8 30.6 28.3 17.9
155 20.5 1.051 27 200.25 73.5 26.1 38.2 101.1 100.1 105 62.1 40 24.9 33.7 29.2 19.4
156 17.2 1.0594 28 171.5 75.25 21.6 35.6 92.1 83.5 98.3 57.3 37.8 21.7 32.2 27.7 17.7
157 30.1 1.0287 28 205.75 69 30.4 38.5 105.6 105 106.4 68.6 40 25.2 35.2 30.7 19.1
158 10.5 1.0761 28 182.5 72.25 24.6 37 98.5 90.8 102.5 60.8 38.5 25 31.6 28 18.6
159 12.8 1.0704 30 136.5 68.75 20.3 35.9 88.7 76.6 89.8 50.1 34.8 21.8 27 34.9 16.9
160 22 1.0477 31 177.25 71.5 24.4 36.2 101.1 92.4 99.3 59.4 39 24.6 30.1 28.2 18.2
161 9.9 1.0775 31 151.25 72.25 20.4 35 94 81.2 91.5 52.5 36.6 21 27 26.3 16.5
162 14.8 1.0653 33 196 73 25.9 38.5 103.8 95.6 105.1 61.4 40.6 25 31.3 29.2 19.1
163 13.3 1.069 33 184.25 68.75 24.4 40.7 98.9 92.1 103.5 64 37.3 23.5 33.5 30.6 19.7
164 15.2 1.0644 34 140 70.5 19.8 36 89.2 83.4 89.6 52.4 35.6 20.4 28.3 26.2 16.5
165 26.5 1.037 34 218.75 72 29.7 39.5 111.4 106 108.8 63.8 42 23.4 34 31.2 18.5
166 19 1.0549 35 217 73.75 28.1 40.5 107.5 95.1 104.5 64.8 41.3 25.6 36.4 33.7 19.4
167 21.4 1.0492 35 166.25 68 25.3 38.5 99.1 90.4 95.6 55.5 34.2 21.9 30.2 28.7 17.7
168 20 1.0525 35 224.75 72.25 30.3 43.9 108.2 100.4 106.8 63.3 41.7 24.6 37.2 33.1 19.8
169 34.7 1.018 35 228.25 69.5 33.3 40.4 114.9 115.9 111.9 74.4 40.6 24 36.1 31.8 18.8
170 16.5 1.061 35 172.75 69.5 25.2 37.6 99.1 90.8 98.1 60.1 39.1 23.4 32.5 29.8 17.4
171 4.1 1.0926 35 152.25 67.75 23.4 37 92.2 81.9 92.8 54.7 36.2 22.1 30.4 27.4 17.7
172 1.9 1.0983 35 125.75 65.5 20.6 34 90.8 75 89.2 50 34.8 22 24.8 25.9 16.9
173 20.2 1.0521 35 177.25 71 24.8 38.4 100.5 90.3 98.7 57.8 37.3 22.4 31 28.7 17.7
174 16.8 1.0603 36 176.25 71.5 24.3 38.7 98.2 90.3 99.9 59.2 37.7 21.5 32.4 28.4 17.8
175 24.6 1.0414 36 226.75 71.75 31 41.5 115.3 108.8 114.4 69.2 42.4 24 35.4 21 20.1
176 10.4 1.0763 37 145.25 69.25 21.3 36 96.8 79.4 89.2 50.3 34.8 22.2 31 26.9 16.9
177 13.4 1.0689 37 151 67 23.7 35.3 92.6 83.2 96.4 60 38.1 22 31.5 26.6 16.7
178 28.8 1.0316 37 241.25 71.5 33.2 42.1 119.2 110.3 113.9 69.8 42.6 24.8 34.4 29.5 18.4
179 22 1.0477 38 187.25 69.25 27.5 38 102.7 92.7 101.9 64.7 39.5 24.7 34.8 30.3 18.1
180 16.8 1.0603 39 234.75 74.5 29.8 42.8 109.5 104.5 109.9 69.5 43.1 25.8 39.1 32.5 19.9
181 25.8 1.0387 39 219.25 74.25 28 40 108.5 104.6 109.8 68.1 42.8 24.1 35.6 29 19
182 0 1.1089 40 118.5 68 18.1 33.8 79.3 69.4 85 47.2 33.5 20.2 27.7 24.6 16.5
183 11.9 1.0725 40 145.75 67.25 22.7 35.5 95.5 83.6 91.6 54.1 36.2 21.8 31.4 28.3 17.2
184 12.4 1.0713 40 159.25 69.75 23 35.3 92.3 86.8 96.1 58 39.4 22.7 30 26.4 17.4
185 17.4 1.0587 40 170.5 74.25 21.8 37.7 98.9 90.4 95.5 55.4 38.9 22.4 30.5 28.9 17.7
186 9.2 1.0794 40 167.5 71.5 23.1 39.4 89.5 83.7 98.1 57.3 39.7 22.6 32.9 29.3 18.2
187 23 1.0453 41 232.75 74.25 29.7 41.9 117.5 109.3 108.8 67.7 41.3 24.7 37.2 31.8 20
188 20.1 1.0524 41 210.5 72 28.6 38.5 107.4 98.9 104.1 63.5 39.8 23.5 36.4 30.4 19.1
189 20.2 1.052 41 202.25 72.5 27 40.8 109.2 98 101.8 62.8 41.3 24.8 36.6 32.4 18.8
190 23.8 1.0434 41 185 68.25 28 38 103.4 101.2 103.1 61.5 40.4 22.9 33.4 29.2 18.5
191 11.8 1.0728 41 153 69.25 22.5 36.4 91.4 80.6 92.3 54.3 36.3 21.8 29.6 27.3 17.9
192 36.5 1.014 42 244.25 76 29.8 41.8 115.2 113.7 112.4 68.5 45 25.5 37.1 31.2 19.9
193 16 1.0624 42 193.5 70.5 27.4 40.7 104.9 94.1 102.7 60.6 38.6 24.7 34 30.1 18.7
194 24 1.0429 42 224.75 74.75 28.3 38.5 106.7 105.7 111.8 65.3 43.3 26 33.7 29.9 18.5
195 22.3 1.047 42 162.75 72.75 21.6 35.4 92.2 85.6 96.5 60.2 38.9 22.4 31.7 27.1 17.1
196 24.8 1.0411 42 180 68.25 27.2 38.5 101.6 96.6 100.6 61.1 38.4 24.1 32.9 29.8 18.8
197 21.5 1.0488 42 156.25 69 23.1 35.5 97.8 86 96.2 57.7 38.6 24 31.2 27.3 17.4
198 17.6 1.0583 42 168 71.5 23.1 36.5 92 89.7 101 62.3 38 22.3 30.8 27.8 16.9
199 7.3 1.0841 42 167.25 72.75 22.3 37.6 94 78 99 57.5 40 22.5 30.6 30 18.5
200 22.6 1.0462 43 170.75 67.5 26.4 37.4 103.7 89.7 94.2 58.5 39 24.1 33.8 28.8 18.8
201 12.5 1.0709 43 178.25 70.25 25.4 37.8 102.7 89.2 99.2 60.2 39.2 23.8 31.7 28.4 18.6
202 21.7 1.0484 43 150 69.25 22 35.2 91.1 85.7 96.9 55.5 35.7 22 29.4 26.6 17.4
203 27.7 1.034 43 200.5 71.5 27.6 37.9 107.2 103.1 105.5 68.8 38.3 23.7 32.1 28.9 18.7
204 6.8 1.0854 44 184 74 23.7 37.9 100.8 89.1 102.6 60.6 39 24 32.9 29.2 18.4
205 33.4 1.0209 44 223 69.75 32.3 40.9 121.6 113.9 107.1 63.5 40.3 21.8 34.8 30.7 17.4
206 16.6 1.061 44 208.75 73 27.6 41.9 105.6 96.3 102 63.3 39.8 24.1 37.3 23.1 19.4
207 31.7 1.025 44 166 65.5 27.2 39.1 100.6 93.9 100.1 58.9 37.6 21.4 33.1 29.5 17.3
208 31.5 1.0254 47 195 72.5 26.1 40.2 102.7 101.3 101.7 60.7 39.4 23.3 36.7 31.6 18.4
209 10.1 1.0771 47 160.5 70.25 22.9 36 99.8 83.9 91.8 53 36.2 22.5 31.4 27.5 17.7
210 11.3 1.0742 47 159.75 70.75 22.5 34.5 92.9 84.4 94 56 38.2 22.6 29 26.2 17.6
211 7.8 1.0829 49 140.5 68 21.4 35.8 91.2 79.4 89 51.1 35 21.7 30.9 28.8 17.4
212 26.4 1.0373 49 216.25 74.5 27.4 40.2 115.6 104 109 63.7 40.3 23.2 36.8 31 18.9
213 19.3 1.0543 49 168.25 71.75 23 38.3 98.3 89.7 99.1 56.3 38.8 23 29.5 27.9 18.6
214 18.5 1.0561 50 194.75 70.75 27.4 39 103.7 97.6 104.2 60 40.9 25.5 32.7 30 19
215 19.3 1.0543 50 172.75 73 22.8 37.4 98.7 87.6 96.1 57.1 38.1 21.8 28.6 26.7 18
216 45.1 0.995 51 219 64 37.6 41.2 119.8 122.1 112.8 62.5 36.9 23.6 34.7 29.1 18.4
217 13.8 1.0678 51 149.25 69.75 21.6 34.8 92.8 81.1 96.3 53.8 36.5 21.5 31.3 26.3 17.8
218 8.2 1.0819 51 154.5 70 22.2 36.9 93.3 81.5 94.4 54.7 39 22.6 27.5 25.9 18.6
219 23.9 1.0433 52 199.25 71.75 27.2 39.4 106.8 100 105 63.9 39.2 22.9 35.7 30.4 19.2
220 15.1 1.0646 53 154.5 69.25 22.7 37.6 93.9 88.7 94.5 53.7 36.2 22 28.5 25.7 17.1
221 12.7 1.0706 54 153.25 70.5 24.5 38.5 99 91.8 96.2 57.7 38.1 23.9 31.4 29.9 18.9
222 25.3 1.0399 54 230 72.25 31 42.5 119.9 110.4 105.5 64.2 42.7 27 38.4 32 19.6
223 11.9 1.0726 54 161.75 67.5 25 37.4 94.2 87.6 95.6 59.7 40.2 23.4 27.9 27 17.8
224 6.1 1.0874 55 142.25 67.25 22.2 35.2 92.7 82.8 91.9 54.4 35.2 22.5 29.4 26.8 17
225 11.3 1.074 55 179.75 68.75 26.8 41.1 106.9 95.3 98.2 57.4 37.1 21.8 34.1 31.1 19.2
226 12.8 1.0703 55 126.5 66.75 20 33.4 88.8 78.2 87.5 50.8 33 19.7 25.3 22 15.8
227 14.9 1.065 55 169.5 68.25 25.6 37.2 101.7 91.1 97.1 56.6 38.5 22.6 33.4 29.3 18.8
228 24.5 1.0418 55 198.5 74.25 25.3 38.3 105.3 96.7 106.6 64 42.6 23.4 33.2 30 18.4
229 15 1.0647 56 174.5 69.5 25.4 38.1 104 89.4 98.4 58.4 37.4 22.5 34.6 30.1 18.8
230 16.9 1.0601 56 167.75 68.5 25.2 37.4 98.6 93 97 55.4 38.8 23.2 32.4 29.7 19
231 11.1 1.0745 57 147.75 65.75 24.1 35.2 99.6 86.4 90.1 53 35 21.3 31.7 27.3 16.9
232 16.1 1.062 57 182.25 71.75 24.9 39.4 103.4 96.7 100.7 59.3 38.6 22.8 31.8 29.1 19
233 15.5 1.0636 58 175.5 71.5 24.2 38 100.2 88.1 97.8 57.1 38.9 23.6 30.9 29.6 18
234 25.9 1.0384 58 161.75 67.25 25.2 35.1 94.9 94.9 100.2 56.8 35.9 21 27.8 26.1 17.6
235 25.5 1.0403 60 157.75 67.5 24.1 40.4 97.2 93.3 94 54.3 35.7 21 31.3 28.7 18.3
236 18.4 1.0563 62 168.75 67.5 26.1 38.3 104.7 95.6 93.7 54.4 37.1 22.7 30.3 26.3 18.3
237 24 1.0424 62 191.5 72.25 25.8 40.6 104 98.2 101.1 59.3 40.3 23 32.6 28.5 19
238 26.4 1.0372 63 219.15 69.5 31.9 40.2 117.6 113.8 111.8 63.4 41.1 22.3 35.1 29.6 18.5
239 12.7 1.0705 64 155.25 69.5 22.6 37.9 95.8 82.8 94.5 61.2 39.1 22.3 29.8 28.9 18.3
240 28.8 1.0316 65 189.75 65.75 30.9 40.8 106.4 100.5 100.5 59.2 38.1 24 35.9 30.5 19.1
241 17 1.0599 65 127.5 65.75 20.8 34.7 93 79.7 87.6 50.7 33.4 20.1 28.5 24.8 16.5
242 33.6 1.0207 65 224.5 68.25 33.9 38.8 119.6 118 114.3 61.3 42.1 23.4 34.9 30.1 19.4
243 29.3 1.0304 66 234.25 72 31.8 41.4 119.7 109 109.1 63.7 42.4 24.6 35.6 30.7 19.5
244 31.4 1.0256 67 227.75 72.75 30.3 41.3 115.8 113.4 109.8 65.6 46 25.4 35.3 29.8 19.5
245 28.1 1.0334 67 199.5 68.5 29.9 40.7 118.3 106.1 101.6 58.2 38.8 24.1 32.1 29.3 18.5
246 15.3 1.0641 68 155.5 69.25 22.8 36.3 97.4 84.3 94.4 54.3 37.5 22.6 29.2 27.3 18.5
247 29.1 1.0308 69 215.5 70.5 30.5 40.8 113.7 107.6 110 63.3 44 22.6 37.5 32.6 18.8
248 11.5 1.0736 70 134.25 67 21.1 34.9 89.2 83.6 88.8 49.6 34.8 21.5 25.6 25.7 18.5
249 32.3 1.0236 72 201 69.75 29.1 40.9 108.5 105 104.5 59.6 40.8 23.2 35.2 28.6 20.1
250 28.3 1.0328 72 186.75 66 30.2 38.9 111.1 111.5 101.7 60.3 37.3 21.5 31.3 27.2 18
251 25.3 1.0399 72 190.75 70.5 27 38.9 108.3 101.3 97.8 56 41.6 22.7 30.5 29.4 19.8
252 30.7 1.0271 74 207.5 70 29.8 40.8 112.4 108.5 107.1 59.3 42.2 24.6 33.7 30 20.9
Here's a solution in ggplot2:
Some illustrative data:
set.seed(123)
Bodytype <- sample(LETTERS[1:3], 500, replace = T)
Weight <- rnorm(500,80,2)
df <- data.frame(Bodytype, Weight)
g <-
ggplot(data = df,
aes(x = Bodytype, y = Weight, fill = Bodytype)) +
geom_violin(scale = "count", trim = F, adjust = 0.75) +
geom_point(aes(y = Weight),
position = position_jitter(width = .15), size = 0.9, alpha = 0.8) +
theme_gray()
g
One-panel plot: plot:
The dataset called bodyfat.csv, I attached the data set in plain text for your reference.
After reading in bodyfat.csv data file, I generated a variable "bodycat" to categorize "bodyfat" into the three categories "athlete", "average", or "obese". (Athlete, less than 14%, Average, 14-25%, Obese, greater than 25%).
Then I created overlapping histograms.
Now I want to add 3 density plots to the exsiting overlapping histograms, 1 for each body category.
bodydata <- read.csv("bodyfat.csv",header=T)
bodycat <- c()
bodycat[bodydata$bodyfat<14]<-"Athlete"
bodycat[bodydata$bodyfat>=14 & bodydata$bodyfat<25]<-"Average"
bodycat[bodydata$bodyfat>=25]<-"Obese"
bodydata <-cbind(bodydata,bodycat)
hist(bodydata$neck[bodydata$bodycat == "Athlete"],
col=rgb(1,0,0,0.25),
xlim = c(30,55),
ylim = c(0,25),
main = "Neck for the three body categories",
xlab = "Body categories",
ylab = "Neck",
breaks=15)
hist(bodydata$neck[bodydata$bodycat == "Average"],
col=rgb(0,0,1,0.25),
breaks=15,
add=T)
hist(bodydata$neck[bodydata$bodycat == "Obese"],
col=rgb(0,1,0,0.25),
breaks=15,
add=T)
legend("topright", c("Athlete", "Average", "Obese"),
col=c(rgb(1,0,0,0.25),rgb(0,0,1,0.25),rgb(0,1,0,0.25)), lwd=15)
dens1 <- density(bodydata$bodycat == "Average", bw = 4)
lines(dens1, lwd = 2)
I recived an error:
Error in density.default(bodydata$bodycat == "Average", bw = 4) :
Parameter 'x' must be numeric
Is there a way to use R to achieve adding density plots to overlapping histograms?
bodyfat.csv in plain text
id bodyfat density age weight height adiposity neck chest abdomen hip thigh knee ankle bicep forearm wrist
1 12.6 1.0708 23 154.25 67.75 23.7 36.2 93.1 85.2 94.5 59 37.3 21.9 32 27.4 17.1
2 6.9 1.0853 22 173.25 72.25 23.4 38.5 93.6 83 98.7 58.7 37.3 23.4 30.5 28.9 18.2
3 24.6 1.0414 22 154 66.25 24.7 34 95.8 87.9 99.2 59.6 38.9 24 28.8 25.2 16.6
4 10.9 1.0751 26 184.75 72.25 24.9 37.4 101.8 86.4 101.2 60.1 37.3 22.8 32.4 29.4 18.2
5 27.8 1.034 24 184.25 71.25 25.6 34.4 97.3 100 101.9 63.2 42.2 24 32.2 27.7 17.7
6 20.6 1.0502 24 210.25 74.75 26.5 39 104.5 94.4 107.8 66 42 25.6 35.7 30.6 18.8
7 19 1.0549 26 181 69.75 26.2 36.4 105.1 90.7 100.3 58.4 38.3 22.9 31.9 27.8 17.7
8 12.8 1.0704 25 176 72.5 23.6 37.8 99.6 88.5 97.1 60 39.4 23.2 30.5 29 18.8
9 5.1 1.09 25 191 74 24.6 38.1 100.9 82.5 99.9 62.9 38.3 23.8 35.9 31.1 18.2
10 12 1.0722 23 198.25 73.5 25.8 42.1 99.6 88.6 104.1 63.1 41.7 25 35.6 30 19.2
11 7.5 1.083 26 186.25 74.5 23.6 38.5 101.5 83.6 98.2 59.7 39.7 25.2 32.8 29.4 18.5
12 8.5 1.0812 27 216 76 26.3 39.4 103.6 90.9 107.7 66.2 39.2 25.9 37.2 30.2 19
13 20.5 1.0513 32 180.5 69.5 26.3 38.4 102 91.6 103.9 63.4 38.3 21.5 32.5 28.6 17.7
14 20.8 1.0505 30 205.25 71.25 28.5 39.4 104.1 101.8 108.6 66 41.5 23.7 36.9 31.6 18.8
15 21.7 1.0484 35 187.75 69.5 27.4 40.5 101.3 96.4 100.1 69 39 23.1 36.1 30.5 18.2
16 20.5 1.0512 35 162.75 66 26.3 36.4 99.1 92.8 99.2 63.1 38.7 21.7 31.1 26.4 16.9
17 28.1 1.0333 34 195.75 71 27.3 38.9 101.9 96.4 105.2 64.8 40.8 23.1 36.2 30.8 17.3
18 22.4 1.0468 32 209.25 71 29.2 42.1 107.6 97.5 107 66.9 40 24.4 38.2 31.6 19.3
19 16.1 1.0622 28 183.75 67.75 28.2 38 106.8 89.6 102.4 64.2 38.7 22.9 37.2 30.5 18.5
20 16.5 1.061 33 211.75 73.5 27.6 40 106.2 100.5 109 65.8 40.6 24 37.1 30.1 18.2
21 19 1.0551 28 179 68 27.3 39.1 103.3 95.9 104.9 63.5 38 22.1 32.5 30.3 18.4
22 15.3 1.064 28 200.5 69.75 29.1 41.3 111.4 98.8 104.8 63.4 40.6 24.6 33 32.8 19.9
23 15.7 1.0631 31 140.25 68.25 21.2 33.9 86 76.4 94.6 57.4 35.3 22.2 27.9 25.9 16.7
24 17.6 1.0584 32 148.75 70 21.4 35.5 86.7 80 93.4 54.9 36.2 22.1 29.8 26.7 17.1
25 14.2 1.0668 28 151.25 67.75 23.2 34.5 90.2 76.3 95.8 58.4 35.5 22.9 31.1 28 17.6
26 4.6 1.0911 27 159.25 71.5 21.9 35.7 89.6 79.7 96.5 55 36.7 22.5 29.9 28.2 17.7
27 8.5 1.0811 34 131.5 67.5 20.3 36.2 88.6 74.6 85.3 51.7 34.7 21.4 28.7 27 16.5
28 22.4 1.0468 31 148 67.5 22.9 38.8 97.4 88.7 94.7 57.5 36 21 29.2 26.6 17
29 4.7 1.091 27 133.25 64.75 22.4 36.4 93.5 73.9 88.5 50.1 34.5 21.3 30.5 27.9 17.2
30 9.4 1.079 29 160.75 69 23.8 36.7 97.4 83.5 98.7 58.9 35.3 22.6 30.1 26.7 17.6
31 12.3 1.0716 32 182 73.75 23.6 38.7 100.5 88.7 99.8 57.5 38.7 33.9 32.5 27.7 18.4
32 6.5 1.0862 29 160.25 71.25 22.2 37.3 93.5 84.5 100.6 58.5 38.8 21.5 30.1 26.4 17.9
33 13.4 1.0719 27 168 71.25 23.3 38.1 93 79.1 94.5 57.3 36.2 24.5 29 30 18.8
34 20.9 1.0502 41 218.5 71 30.5 39.8 111.7 100.5 108.3 67.1 44.2 25.2 37.5 31.5 18.7
35 31.1 1.0263 41 247.25 73.5 32.2 42.1 117 115.6 116.1 71.2 43.3 26.3 37.3 31.7 19.7
36 38.2 1.0101 49 191.75 65 32 38.4 118.5 113.1 113.8 61.9 38.3 21.9 32 29.8 17
37 23.6 1.0438 40 202.25 70 29.1 38.5 106.5 100.9 106.2 63.5 39.9 22.6 35.1 30.6 19
38 27.5 1.0346 50 196.75 68.25 29.7 42.1 105.6 98.8 104.8 66 41.5 24.7 33.2 30.5 19.4
39 33.8 1.0202 46 363.15 72.25 48.9 51.2 136.2 148.1 147.7 87.3 49.1 29.6 45 29 21.4
40 31.3 1.0258 50 203 67 31.8 40.2 114.8 108.1 102.5 61.3 41.1 24.7 34.1 31 18.3
41 33.1 1.0217 45 262.75 68.75 39.1 43.2 128.3 126.2 125.6 72.5 39.6 26.6 36.4 32.7 21.4
42 31.7 1.025 44 205 29.5 29.9 36.6 106 104.3 115.5 70.6 42.5 23.7 33.6 28.7 17.4
43 30.4 1.0279 48 217 70 31.2 37.3 113.3 111.2 114.1 67.7 40.9 25 36.7 29.8 18.4
44 30.8 1.0269 41 212 71.5 29.2 41.5 106.6 104.3 106 65 40.2 23 35.8 31.5 18.8
45 8.4 1.0814 39 125.25 68 19.1 31.5 85.1 76 88.2 50 34.7 21 26.1 23.1 16.1
46 14.1 1.067 43 164.25 73.25 21.3 35.7 96.6 81.5 97.2 58.4 38.2 23.4 29.7 27.4 18.3
47 11.2 1.0742 40 133.5 67.5 20.6 33.6 88.2 73.7 88.5 53.3 34.5 22.5 27.9 26.2 17.3
48 6.4 1.0665 39 148.5 71.25 20.6 34.6 89.8 79.5 92.7 52.7 37.5 21.9 28.8 26.8 17.9
49 13.4 1.0678 45 135.75 68.5 20.4 32.8 92.3 83.4 90.4 52 35.8 20.6 28.8 25.5 16.3
50 5 1.0903 47 127.5 66.75 20.2 34 83.4 70.4 87.2 50.6 34.4 21.9 26.8 25.8 16.8
51 10.7 1.0756 47 158.25 72.25 21.3 34.9 90.2 86.7 98.3 52.6 37.2 22.4 26 25.8 17.3
52 7.4 1.084 40 139.25 69 20.6 34.3 89.2 77.9 91 51.4 34.9 21 26.7 26.1 17.2
53 8.7 1.0807 51 137.25 67.75 21.1 36.5 89.7 82 89.1 49.3 33.7 21.4 29.6 26 16.9
54 7.1 1.0848 49 152.75 73.5 19.9 35.1 93.3 79.6 91.6 52.6 37.6 22.6 38.5 27.4 18.5
55 4.9 1.0906 42 136.25 67.5 21.1 37.8 87.6 77.6 88.6 51.9 34.9 22.5 27.7 27.5 18.5
56 22.2 1.0473 54 198 72 26.9 39.9 107.6 100 99.6 57.2 38 22 35.9 30.2 18.9
57 20.1 1.0524 58 181.5 68 27.6 39.1 100 99.8 102.5 62.1 39.6 22.5 33.1 28.3 18.5
58 27.1 1.0356 62 201.25 69.5 29.3 40.5 111.5 104.2 105.8 61.8 39.8 22.7 37.7 30.9 19.2
59 30.4 1.028 54 202.5 70.75 28.4 40.5 115.4 105.3 97 59.1 38 22.5 31.6 28.8 18.2
60 24 1.043 61 179.75 65.75 29.2 38.4 104.8 98.3 99.6 60.6 37.7 22.9 34.5 29.6 18.5
61 25.4 1.0396 62 216 73.25 28.2 41.4 112.3 104.8 103.1 61.6 40.9 23.1 36.2 31.8 20.2
62 28.8 1.0317 56 178.75 68.5 26.8 35.6 102.9 94.7 100.8 60.9 38 22.1 32.5 29.8 18.3
63 29.6 1.0298 54 193.25 70.25 27.6 38 107.6 102.4 99.4 61 39.4 23.6 32.7 29.9 19.1
64 25.1 1.0403 61 178 67 27.9 37.4 105.3 99.7 99.7 60.8 40.1 22.7 33.6 29 18.8
65 31 1.0264 57 205.5 70 29.5 40.1 105.3 105.5 108.3 65 41.2 24.7 35.3 31.1 18.4
66 28.9 1.0313 55 183.5 67.5 28.3 40.9 103 100.3 104.2 64.8 40.2 22.7 34.8 30.1 18.7
67 21.1 1.0499 54 151.5 70.75 21.3 35.6 90 83.9 93.9 55 36.1 21.7 29.6 27.4 17.4
68 14 1.0673 55 154.75 71.5 21.3 36.9 95.4 86.6 91.8 54.3 35.4 21.5 32.8 27.4 18.7
69 7.1 1.0847 54 155.25 69.25 22.8 37.5 89.3 78.4 96.1 56 37.4 22.4 32.6 28.1 18.1
70 13.2 1.0693 55 156.75 71.5 21.6 36.3 94.4 84.6 94.3 51.2 37.4 21.6 27.3 27.1 17.3
71 23.7 1.0439 62 167.5 71.5 23.1 35.5 97.6 91.5 98.5 56.6 38.6 22.4 31.5 27.3 18.6
72 9.4 1.0788 55 146.75 68.75 21.9 38.7 88.5 82.8 95.5 58.9 37.6 21.6 30.3 27.3 18.3
73 9.1 1.0796 56 160.75 73.75 20.8 36.4 93.6 82.9 96.3 52.9 37.5 23.1 29.7 27.3 18.2
74 13.7 1.068 55 125 64 21.5 33.2 87.7 76 88.6 50.9 35.4 19.1 29.3 25.7 16.9
75 12 1.072 61 143 65.75 23.3 36.5 93.4 83.3 93 55.5 35.2 20.9 29.4 27 16.8
76 18.3 1.0666 61 148.25 67.5 22.9 36 91.6 81.8 94.8 54.5 37 21.4 29.3 27 18.3
77 9.2 1.079 57 162.5 69.5 23.7 38.7 91.6 78.8 94.3 56.7 39.7 24.2 30.2 29.2 18.1
78 21.7 1.0483 69 177.75 68.5 26.7 38.7 102 95 98.3 55 38.3 21.8 30.8 25.7 18.8
79 21.1 1.0498 81 161.25 70.25 23 37.8 96.4 95.4 99.3 53.5 37.5 21.5 31.4 26.8 18.3
80 18.6 1.056 66 171.25 69.25 25.1 37.4 102.7 98.6 100.2 56.5 39.3 22.7 30.3 28.7 19
81 30.2 1.0283 67 163.75 67.75 25.1 38.4 97.7 95.8 97.1 54.8 38.2 23.7 29.4 27.2 19
82 26 1.0382 64 150.25 67.25 23.4 38.1 97.1 89 96.9 54.8 38 22 29.9 25.2 17.7
83 18.2 1.0568 64 190.25 72.75 25.3 39.3 103.1 97.8 99.6 58.9 39 23 34.3 29.6 19
84 26.2 1.0377 70 170.75 70 24.5 38.7 101.8 94.9 95 56 36.5 24.1 31.2 27.3 19.2
85 26.1 1.0378 72 168 69.25 24.7 38.5 101.4 99.8 96.2 56.3 36.6 22 29.7 26.3 18
86 25.8 1.0386 67 167 67.5 26 36.5 98.9 89.7 96.2 54.7 37.8 33.7 32.4 27.7 18.2
87 15 1.0648 72 157.75 67.25 24.6 37.7 97.5 88.1 96.9 57.2 37.7 21.8 32.6 28 18.8
88 22.6 1.0462 64 160 65.75 26 36.5 104.3 90.9 93.8 57.8 39.5 23.3 29.2 28.4 18.1
89 8.8 1.08 46 176.75 72.5 23.7 38 97.3 86 99.3 61 38.4 23.8 30.2 29.3 18.8
90 14.3 1.0666 48 176 73 23.3 36.7 96.7 86.5 98.3 60.4 39.9 24.4 28.8 29.6 18.7
91 20.2 1.052 46 177 70 25.4 37.2 99.7 95.6 102.2 58.3 38.2 22.5 29.1 27.7 17.7
92 18.1 1.0573 44 179.75 69.5 26.2 39.2 101.9 93.2 100.6 58.9 39.7 23.1 31.4 28.4 18.8
93 9.2 1.0795 47 165.25 70.5 23.4 37.5 97.2 83.1 95.4 56.9 38.3 22.1 30.1 28.2 18.4
94 24.2 1.0424 46 192.5 71.75 26.3 38 106.6 97.5 100.6 58.9 40.5 24.5 33.3 29.6 19.1
95 9.6 1.0785 47 184.25 74.5 23.4 37.3 99.6 88.8 101.4 57.4 39.6 24.6 30.3 27.9 17.8
96 17.3 1.0991 53 224.5 77.75 26.1 41.1 113.2 99.2 107.5 61.7 42.3 23.2 32.9 30.8 20.4
97 10.1 1.077 38 188.75 73.25 24.8 37.5 99.1 91.6 102.4 60.6 39.4 22.9 31.6 30.1 18.5
98 11.1 1.073 50 162.5 66.5 25.9 38.7 99.4 86.7 96.2 62.1 39.3 23.3 30.6 27.8 18.2
99 17.7 1.0582 46 156.5 68.25 23.7 35.9 95.1 88.2 92.8 54.7 37.3 21.9 31.6 27.5 18.2
100 21.7 1.0484 47 197 72 26.7 40 107.5 94 103.7 62.7 39 22.3 35.3 30.9 18.3
101 20.8 1.0506 49 198.5 73.5 25.9 40.1 106.5 95 101.7 59 39.4 22.3 32.2 31 18.6
102 20.1 1.0524 48 173.75 72 23.6 37 99.1 92 98.3 59.3 38.4 22.4 27.9 26.2 17
103 19.8 1.053 41 172.75 71.25 24 36.3 96.7 89.2 98.3 60 38.4 23.2 31 29.2 18.4
104 21.9 1.048 49 196.75 73.75 25.5 40.7 103.5 95.5 101.6 59.1 39.8 25.4 31 30.3 19.7
105 24.7 1.0412 43 177 69.25 26 39.6 104 98.6 99.5 59.5 36.1 22 30.1 27.2 17.7
106 17.8 1.0578 43 165.5 68.5 24.8 31.1 93.1 87.3 96.6 54.7 39 24.8 31 29.4 18.8
107 19.1 1.0547 43 200.25 73.5 26 38.6 105.2 102.8 103.6 61.2 39.3 23.5 30.5 28.5 18.1
108 18.2 1.0569 52 203.25 74.25 26 42 110 101.6 100.7 55.8 38.7 23.4 35.1 29.6 19.1
109 17.2 1.0593 43 194 75.5 24 38.5 110.1 88.7 102.1 57.5 40 24.8 35.1 30.7 19.2
110 21 1.05 40 168.5 69.25 24.7 34.2 97.8 92.3 100.6 57.5 36.8 22.8 32.1 26 17.3
111 19.5 1.0538 43 170.75 68.5 25.6 37.2 96.3 90.6 99.3 61.9 38 22.3 33.3 28.2 18.1
112 27.1 1.0355 43 183.25 70 26.3 37.1 108 105 103 63.7 40 23.6 33.5 27.8 17.4
113 21.6 1.0486 47 178.25 70 25.6 40.2 99.7 95 98.6 62.3 38.1 23.9 35.3 31.1 19.8
114 20.9 1.0503 42 163 70.25 23.3 35.3 93.5 89.6 99.8 61.5 37.8 21.9 30.7 27.6 17.4
115 25.9 1.0384 48 175.25 71.75 24 38 100.7 92.4 97.5 59.3 38.1 21.8 31.8 27.3 17.5
116 16.7 1.0607 40 158 69.25 23.4 36.3 97 86.6 92.6 55.9 36.3 22.1 29.8 26.3 17.3
117 19.8 1.0529 48 177.25 72.75 23.6 36.8 96 90 99.7 58.8 38.4 22.8 29.9 28 18.1
118 14.1 1.0671 51 179 72 24.3 41 99.2 90 96.4 56.8 38.8 23.3 33.4 29.8 19.5
119 25.1 1.0404 40 191 74 24.6 38.3 95.4 92.4 104.3 64.6 41.1 24.8 33.6 29.5 18.5
120 17.9 1.0575 44 187.5 72.25 25.3 38 101.8 87.5 101 58.5 39.2 24.5 32.1 28.6 18
121 27 1.0358 52 206.5 74.5 26.2 40.8 104.3 99.2 104.1 58.5 39.3 24.6 33.9 31.2 19.5
122 24.6 1.0414 44 185.25 71.5 25.5 39.5 99.2 98.1 101.4 57.1 40.5 23.2 33 29.6 18.4
123 14.8 1.0652 40 160.25 68.75 23.9 36.9 99.3 83.3 97.5 60.5 38.7 22.6 34.4 28 17.6
124 16 1.0623 47 151.5 66.75 23.9 36.9 94 86.1 95.2 58.1 36.5 22.1 30.6 27.5 17.6
125 14 1.0674 50 161 66.5 25.6 37.7 98.9 84.1 94 58.5 36.6 23.5 34.4 29.2 18
126 17.4 1.0587 46 167 67 26.2 36.6 101 89.9 100 60.7 36 21.9 35.6 30.2 17.6
127 26.4 1.0373 42 177.5 68.75 26.4 38.9 98.7 92.1 98.5 60.7 36.8 22.2 33.8 30.3 17.2
128 17.4 1.059 43 152.25 67.75 23.4 37.5 95.9 78 93.2 53.5 35.8 20.8 33.9 28.2 17.4
129 20.4 1.0515 40 192.25 73.25 25.2 39.8 103.9 93.5 99.5 61.7 39 21.8 33.3 29.6 18.1
130 15 1.0648 42 165.25 69.75 23.9 38.3 96.2 87 97.8 57.4 36.9 22.2 31.6 27.8 17.7
131 18 1.0575 49 171.75 71.5 23.7 35.5 97.8 90.1 95.8 57 38.7 23.2 27.5 26.5 17.6
132 22.2 1.0472 40 171.25 70.5 24.3 36.3 94.6 90.3 99.1 60.3 38.5 23 31.2 28.4 17.1
133 23.1 1.0452 47 197 73.25 25.8 37.8 103.6 99.8 103.2 61.2 38.1 22.6 33.5 28.6 17.9
134 25.3 1.0398 50 157 66.75 24.8 37.8 100.4 89.4 92.3 56.1 35.6 20.5 33.6 29.3 17.3
135 23.8 1.0435 41 168.25 69.5 24.5 36.5 98.4 87.2 98.4 56 36.9 23 34 29.8 18.1
136 26.3 1.0374 44 186 69.75 26.8 37.8 104.6 101.1 102.1 58.9 37.9 22.7 30.9 28.8 17.6
137 21.4 1.0491 39 166.75 70.75 23.5 37 92.9 86.1 95.6 58.8 36.1 22.4 32.7 28.3 17.1
138 28.4 1.0325 43 187.75 74 24.1 37.7 97.8 98.6 100.6 63.6 39.2 23.8 34.3 28.4 17.7
139 21.8 1.0481 40 168.25 71.25 23.3 34.3 98.3 88.5 98.3 58.1 38.4 22.5 31.7 27.4 17.6
140 20.1 1.0522 49 212.75 75 26.6 40.8 104.7 106.6 107.7 66.5 42.5 24.5 35.5 29.8 18.7
141 24.3 1.0422 40 176.75 71 24.6 37.4 98.6 93.1 101.6 59.1 39.6 21.6 30.8 27.9 16.6
142 18.1 1.0571 40 173.25 69.5 25.3 36.5 99.5 93 99.3 60.4 38.2 22 32 28.5 17.8
143 22.7 1.0459 52 167 67.75 25.6 37.5 102.7 91 98.9 57.1 36.7 22.3 31.6 27.5 17.9
144 9.9 1.0775 23 159.75 72.25 21.6 35.5 92.1 77.1 93.9 56.1 36.1 22.7 30.5 27.2 18.2
145 10.8 1.0754 23 188.15 77.5 22.1 38 96.6 85.3 102.5 59.1 37.6 23.2 31.8 29.7 18.3
146 14.4 1.0664 24 156 70.75 21.9 35.7 92.7 81.9 95.3 56.4 36.5 22 33.5 28.3 17.3
147 19 1.055 24 208.5 72.75 27.7 39.2 102 99.1 110.1 71.2 43.5 25.2 36.1 30.3 18.7
148 28.6 1.0322 25 206.5 69.75 29.8 40.9 110.9 100.5 106.2 68.4 40.8 24.6 33.3 29.7 18.4
149 6.1 1.0873 25 143.75 72.5 19.3 35.2 92.3 76.5 92.1 51.9 35.7 22 25.8 25.2 16.9
150 24.5 1.0416 26 223 70.25 31.8 40.6 114.1 106.8 113.9 67.6 42.7 24.7 36 30.4 18.4
151 9.9 1.0776 26 152.25 69 22.5 35.4 92.9 77.6 93.5 56.9 35.9 20.4 31.6 29 17.8
152 19.1 1.0542 26 241.75 74.5 30.7 41.8 108.3 102.9 114.4 72.9 43.5 25.1 38.5 33.8 19.6
153 10.6 1.0758 27 146 72.25 19.7 34.1 88.5 72.8 91.1 53.6 36.8 23.8 27.8 26.3 17.4
154 16.5 1.061 27 156.75 67.25 24.4 37.9 94 88.2 95.2 56.8 37.4 22.8 30.6 28.3 17.9
155 20.5 1.051 27 200.25 73.5 26.1 38.2 101.1 100.1 105 62.1 40 24.9 33.7 29.2 19.4
156 17.2 1.0594 28 171.5 75.25 21.6 35.6 92.1 83.5 98.3 57.3 37.8 21.7 32.2 27.7 17.7
157 30.1 1.0287 28 205.75 69 30.4 38.5 105.6 105 106.4 68.6 40 25.2 35.2 30.7 19.1
158 10.5 1.0761 28 182.5 72.25 24.6 37 98.5 90.8 102.5 60.8 38.5 25 31.6 28 18.6
159 12.8 1.0704 30 136.5 68.75 20.3 35.9 88.7 76.6 89.8 50.1 34.8 21.8 27 34.9 16.9
160 22 1.0477 31 177.25 71.5 24.4 36.2 101.1 92.4 99.3 59.4 39 24.6 30.1 28.2 18.2
161 9.9 1.0775 31 151.25 72.25 20.4 35 94 81.2 91.5 52.5 36.6 21 27 26.3 16.5
162 14.8 1.0653 33 196 73 25.9 38.5 103.8 95.6 105.1 61.4 40.6 25 31.3 29.2 19.1
163 13.3 1.069 33 184.25 68.75 24.4 40.7 98.9 92.1 103.5 64 37.3 23.5 33.5 30.6 19.7
164 15.2 1.0644 34 140 70.5 19.8 36 89.2 83.4 89.6 52.4 35.6 20.4 28.3 26.2 16.5
165 26.5 1.037 34 218.75 72 29.7 39.5 111.4 106 108.8 63.8 42 23.4 34 31.2 18.5
166 19 1.0549 35 217 73.75 28.1 40.5 107.5 95.1 104.5 64.8 41.3 25.6 36.4 33.7 19.4
167 21.4 1.0492 35 166.25 68 25.3 38.5 99.1 90.4 95.6 55.5 34.2 21.9 30.2 28.7 17.7
168 20 1.0525 35 224.75 72.25 30.3 43.9 108.2 100.4 106.8 63.3 41.7 24.6 37.2 33.1 19.8
169 34.7 1.018 35 228.25 69.5 33.3 40.4 114.9 115.9 111.9 74.4 40.6 24 36.1 31.8 18.8
170 16.5 1.061 35 172.75 69.5 25.2 37.6 99.1 90.8 98.1 60.1 39.1 23.4 32.5 29.8 17.4
171 4.1 1.0926 35 152.25 67.75 23.4 37 92.2 81.9 92.8 54.7 36.2 22.1 30.4 27.4 17.7
172 1.9 1.0983 35 125.75 65.5 20.6 34 90.8 75 89.2 50 34.8 22 24.8 25.9 16.9
173 20.2 1.0521 35 177.25 71 24.8 38.4 100.5 90.3 98.7 57.8 37.3 22.4 31 28.7 17.7
174 16.8 1.0603 36 176.25 71.5 24.3 38.7 98.2 90.3 99.9 59.2 37.7 21.5 32.4 28.4 17.8
175 24.6 1.0414 36 226.75 71.75 31 41.5 115.3 108.8 114.4 69.2 42.4 24 35.4 21 20.1
176 10.4 1.0763 37 145.25 69.25 21.3 36 96.8 79.4 89.2 50.3 34.8 22.2 31 26.9 16.9
177 13.4 1.0689 37 151 67 23.7 35.3 92.6 83.2 96.4 60 38.1 22 31.5 26.6 16.7
178 28.8 1.0316 37 241.25 71.5 33.2 42.1 119.2 110.3 113.9 69.8 42.6 24.8 34.4 29.5 18.4
179 22 1.0477 38 187.25 69.25 27.5 38 102.7 92.7 101.9 64.7 39.5 24.7 34.8 30.3 18.1
180 16.8 1.0603 39 234.75 74.5 29.8 42.8 109.5 104.5 109.9 69.5 43.1 25.8 39.1 32.5 19.9
181 25.8 1.0387 39 219.25 74.25 28 40 108.5 104.6 109.8 68.1 42.8 24.1 35.6 29 19
182 0 1.1089 40 118.5 68 18.1 33.8 79.3 69.4 85 47.2 33.5 20.2 27.7 24.6 16.5
183 11.9 1.0725 40 145.75 67.25 22.7 35.5 95.5 83.6 91.6 54.1 36.2 21.8 31.4 28.3 17.2
184 12.4 1.0713 40 159.25 69.75 23 35.3 92.3 86.8 96.1 58 39.4 22.7 30 26.4 17.4
185 17.4 1.0587 40 170.5 74.25 21.8 37.7 98.9 90.4 95.5 55.4 38.9 22.4 30.5 28.9 17.7
186 9.2 1.0794 40 167.5 71.5 23.1 39.4 89.5 83.7 98.1 57.3 39.7 22.6 32.9 29.3 18.2
187 23 1.0453 41 232.75 74.25 29.7 41.9 117.5 109.3 108.8 67.7 41.3 24.7 37.2 31.8 20
188 20.1 1.0524 41 210.5 72 28.6 38.5 107.4 98.9 104.1 63.5 39.8 23.5 36.4 30.4 19.1
189 20.2 1.052 41 202.25 72.5 27 40.8 109.2 98 101.8 62.8 41.3 24.8 36.6 32.4 18.8
190 23.8 1.0434 41 185 68.25 28 38 103.4 101.2 103.1 61.5 40.4 22.9 33.4 29.2 18.5
191 11.8 1.0728 41 153 69.25 22.5 36.4 91.4 80.6 92.3 54.3 36.3 21.8 29.6 27.3 17.9
192 36.5 1.014 42 244.25 76 29.8 41.8 115.2 113.7 112.4 68.5 45 25.5 37.1 31.2 19.9
193 16 1.0624 42 193.5 70.5 27.4 40.7 104.9 94.1 102.7 60.6 38.6 24.7 34 30.1 18.7
194 24 1.0429 42 224.75 74.75 28.3 38.5 106.7 105.7 111.8 65.3 43.3 26 33.7 29.9 18.5
195 22.3 1.047 42 162.75 72.75 21.6 35.4 92.2 85.6 96.5 60.2 38.9 22.4 31.7 27.1 17.1
196 24.8 1.0411 42 180 68.25 27.2 38.5 101.6 96.6 100.6 61.1 38.4 24.1 32.9 29.8 18.8
197 21.5 1.0488 42 156.25 69 23.1 35.5 97.8 86 96.2 57.7 38.6 24 31.2 27.3 17.4
198 17.6 1.0583 42 168 71.5 23.1 36.5 92 89.7 101 62.3 38 22.3 30.8 27.8 16.9
199 7.3 1.0841 42 167.25 72.75 22.3 37.6 94 78 99 57.5 40 22.5 30.6 30 18.5
200 22.6 1.0462 43 170.75 67.5 26.4 37.4 103.7 89.7 94.2 58.5 39 24.1 33.8 28.8 18.8
201 12.5 1.0709 43 178.25 70.25 25.4 37.8 102.7 89.2 99.2 60.2 39.2 23.8 31.7 28.4 18.6
202 21.7 1.0484 43 150 69.25 22 35.2 91.1 85.7 96.9 55.5 35.7 22 29.4 26.6 17.4
203 27.7 1.034 43 200.5 71.5 27.6 37.9 107.2 103.1 105.5 68.8 38.3 23.7 32.1 28.9 18.7
204 6.8 1.0854 44 184 74 23.7 37.9 100.8 89.1 102.6 60.6 39 24 32.9 29.2 18.4
205 33.4 1.0209 44 223 69.75 32.3 40.9 121.6 113.9 107.1 63.5 40.3 21.8 34.8 30.7 17.4
206 16.6 1.061 44 208.75 73 27.6 41.9 105.6 96.3 102 63.3 39.8 24.1 37.3 23.1 19.4
207 31.7 1.025 44 166 65.5 27.2 39.1 100.6 93.9 100.1 58.9 37.6 21.4 33.1 29.5 17.3
208 31.5 1.0254 47 195 72.5 26.1 40.2 102.7 101.3 101.7 60.7 39.4 23.3 36.7 31.6 18.4
209 10.1 1.0771 47 160.5 70.25 22.9 36 99.8 83.9 91.8 53 36.2 22.5 31.4 27.5 17.7
210 11.3 1.0742 47 159.75 70.75 22.5 34.5 92.9 84.4 94 56 38.2 22.6 29 26.2 17.6
211 7.8 1.0829 49 140.5 68 21.4 35.8 91.2 79.4 89 51.1 35 21.7 30.9 28.8 17.4
212 26.4 1.0373 49 216.25 74.5 27.4 40.2 115.6 104 109 63.7 40.3 23.2 36.8 31 18.9
213 19.3 1.0543 49 168.25 71.75 23 38.3 98.3 89.7 99.1 56.3 38.8 23 29.5 27.9 18.6
214 18.5 1.0561 50 194.75 70.75 27.4 39 103.7 97.6 104.2 60 40.9 25.5 32.7 30 19
215 19.3 1.0543 50 172.75 73 22.8 37.4 98.7 87.6 96.1 57.1 38.1 21.8 28.6 26.7 18
216 45.1 0.995 51 219 64 37.6 41.2 119.8 122.1 112.8 62.5 36.9 23.6 34.7 29.1 18.4
217 13.8 1.0678 51 149.25 69.75 21.6 34.8 92.8 81.1 96.3 53.8 36.5 21.5 31.3 26.3 17.8
218 8.2 1.0819 51 154.5 70 22.2 36.9 93.3 81.5 94.4 54.7 39 22.6 27.5 25.9 18.6
219 23.9 1.0433 52 199.25 71.75 27.2 39.4 106.8 100 105 63.9 39.2 22.9 35.7 30.4 19.2
220 15.1 1.0646 53 154.5 69.25 22.7 37.6 93.9 88.7 94.5 53.7 36.2 22 28.5 25.7 17.1
221 12.7 1.0706 54 153.25 70.5 24.5 38.5 99 91.8 96.2 57.7 38.1 23.9 31.4 29.9 18.9
222 25.3 1.0399 54 230 72.25 31 42.5 119.9 110.4 105.5 64.2 42.7 27 38.4 32 19.6
223 11.9 1.0726 54 161.75 67.5 25 37.4 94.2 87.6 95.6 59.7 40.2 23.4 27.9 27 17.8
224 6.1 1.0874 55 142.25 67.25 22.2 35.2 92.7 82.8 91.9 54.4 35.2 22.5 29.4 26.8 17
225 11.3 1.074 55 179.75 68.75 26.8 41.1 106.9 95.3 98.2 57.4 37.1 21.8 34.1 31.1 19.2
226 12.8 1.0703 55 126.5 66.75 20 33.4 88.8 78.2 87.5 50.8 33 19.7 25.3 22 15.8
227 14.9 1.065 55 169.5 68.25 25.6 37.2 101.7 91.1 97.1 56.6 38.5 22.6 33.4 29.3 18.8
228 24.5 1.0418 55 198.5 74.25 25.3 38.3 105.3 96.7 106.6 64 42.6 23.4 33.2 30 18.4
229 15 1.0647 56 174.5 69.5 25.4 38.1 104 89.4 98.4 58.4 37.4 22.5 34.6 30.1 18.8
230 16.9 1.0601 56 167.75 68.5 25.2 37.4 98.6 93 97 55.4 38.8 23.2 32.4 29.7 19
231 11.1 1.0745 57 147.75 65.75 24.1 35.2 99.6 86.4 90.1 53 35 21.3 31.7 27.3 16.9
232 16.1 1.062 57 182.25 71.75 24.9 39.4 103.4 96.7 100.7 59.3 38.6 22.8 31.8 29.1 19
233 15.5 1.0636 58 175.5 71.5 24.2 38 100.2 88.1 97.8 57.1 38.9 23.6 30.9 29.6 18
234 25.9 1.0384 58 161.75 67.25 25.2 35.1 94.9 94.9 100.2 56.8 35.9 21 27.8 26.1 17.6
235 25.5 1.0403 60 157.75 67.5 24.1 40.4 97.2 93.3 94 54.3 35.7 21 31.3 28.7 18.3
236 18.4 1.0563 62 168.75 67.5 26.1 38.3 104.7 95.6 93.7 54.4 37.1 22.7 30.3 26.3 18.3
237 24 1.0424 62 191.5 72.25 25.8 40.6 104 98.2 101.1 59.3 40.3 23 32.6 28.5 19
238 26.4 1.0372 63 219.15 69.5 31.9 40.2 117.6 113.8 111.8 63.4 41.1 22.3 35.1 29.6 18.5
239 12.7 1.0705 64 155.25 69.5 22.6 37.9 95.8 82.8 94.5 61.2 39.1 22.3 29.8 28.9 18.3
240 28.8 1.0316 65 189.75 65.75 30.9 40.8 106.4 100.5 100.5 59.2 38.1 24 35.9 30.5 19.1
241 17 1.0599 65 127.5 65.75 20.8 34.7 93 79.7 87.6 50.7 33.4 20.1 28.5 24.8 16.5
242 33.6 1.0207 65 224.5 68.25 33.9 38.8 119.6 118 114.3 61.3 42.1 23.4 34.9 30.1 19.4
243 29.3 1.0304 66 234.25 72 31.8 41.4 119.7 109 109.1 63.7 42.4 24.6 35.6 30.7 19.5
244 31.4 1.0256 67 227.75 72.75 30.3 41.3 115.8 113.4 109.8 65.6 46 25.4 35.3 29.8 19.5
245 28.1 1.0334 67 199.5 68.5 29.9 40.7 118.3 106.1 101.6 58.2 38.8 24.1 32.1 29.3 18.5
246 15.3 1.0641 68 155.5 69.25 22.8 36.3 97.4 84.3 94.4 54.3 37.5 22.6 29.2 27.3 18.5
247 29.1 1.0308 69 215.5 70.5 30.5 40.8 113.7 107.6 110 63.3 44 22.6 37.5 32.6 18.8
248 11.5 1.0736 70 134.25 67 21.1 34.9 89.2 83.6 88.8 49.6 34.8 21.5 25.6 25.7 18.5
249 32.3 1.0236 72 201 69.75 29.1 40.9 108.5 105 104.5 59.6 40.8 23.2 35.2 28.6 20.1
250 28.3 1.0328 72 186.75 66 30.2 38.9 111.1 111.5 101.7 60.3 37.3 21.5 31.3 27.2 18
251 25.3 1.0399 72 190.75 70.5 27 38.9 108.3 101.3 97.8 56 41.6 22.7 30.5 29.4 19.8
252 30.7 1.0271 74 207.5 70 29.8 40.8 112.4 108.5 107.1 59.3 42.2 24.6 33.7 30 20.9
I think to solve your error, you should write:
dens1 <- density(bodydata$neck[bodydata$bodycat == "Average"], bw = 4)
So, with slightly change in your code, you can write:
h1 <- hist(bodydata$neck[bodydata$bodycat == "Athlete"], plot = FALSE, breaks = 15)
h2 <- hist(bodydata$neck[bodydata$bodycat == "Average"], plot = FALSE, breaks = 15)
h3 <- hist(bodydata$neck[bodydata$bodycat == "Obese"], plot = FALSE, breaks = 15)
plot(h1, add = FALSE, col=rgb(1,0,0,0.25), xlim = c(30,55), ylim = c(0,25),
main = "Neck for the three body categories",
xlab = "Body categories",
ylab = "Neck")
plot(h2, add = TRUE, col = rgb(0,0,1,0.25))
plot(h3, add = TRUE, col = rgb(0,1,0,0.25))
legend("topright", c("Athlete", "Average", "Obese"),
col=c(rgb(1,0,0,0.25),rgb(0,0,1,0.25),rgb(0,1,0,0.25)), lwd=15)
dens1 <- density(bodydata$neck[bodydata$bodycat == "Athlete"], bw = 4)
dens2 <- density(bodydata$neck[bodydata$bodycat == "Average"], bw = 4)
dens3 <- density(bodydata$neck[bodydata$bodycat == "Obese"], bw = 4)
lines(x = dens1$x, y = dens1$y*length(bodydata$neck[bodydata$bodycat == "Athlete"])*diff(h1$breaks)[1], lwd = 2, col = rgb(1,0,0))
lines(x = dens2$x, y = dens2$y*length(bodydata$neck[bodydata$bodycat == "Average"])*diff(h2$breaks)[1], lwd = 2, col = rgb(0,0,1))
lines(x = dens3$x, y = dens3$y*length(bodydata$neck[bodydata$bodycat == "Obese"])*diff(h3$breaks)[1], lwd = 2, col = rgb(0,1,0))
If you don't have to stay with R base plot, you can use ggplot2, to get all histograms and density plots together in fewer lines and separate them in three different panels using facet_wrap. This will improve the readibility of your graph and of your code:
library(ggplot2)
ggplot(bodydata, aes(neck, fill = bodycat))+
geom_histogram(aes(y = ..count..),color = "black", alpha = 0.25)+
geom_density(aes(y = ..count.., color = bodycat), fill = NA, alpha = 0.25)+
facet_wrap(.~bodycat)
I want to compute the rolling mean over a vector whereby the window grows with each entry in the vector. Basically, I want to have the mean of all elements up to the i-th, i+1-th, i+2-th, and so forth.
To make it more clear, I'll provide an example and a solution which works for smaller datasets but does not scale up well:
library(zoo)
# data:
x <- 1:100
# solution:
rolling_average <- rollapply(x, seq_along(x), mean, align = "right")
# result:
rolling_average
# [1] 1.0 1.5 2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5 6.0 6.5 7.0 7.5 8.0 8.5 9.0 9.5 10.0 10.5 11.0 11.5 12.0 12.5 13.0 13.5
# [27] 14.0 14.5 15.0 15.5 16.0 16.5 17.0 17.5 18.0 18.5 19.0 19.5 20.0 20.5 21.0 21.5 22.0 22.5 23.0 23.5 24.0 24.5 25.0 25.5 26.0 26.5
# [53] 27.0 27.5 28.0 28.5 29.0 29.5 30.0 30.5 31.0 31.5 32.0 32.5 33.0 33.5 34.0 34.5 35.0 35.5 36.0 36.5 37.0 37.5 38.0 38.5 39.0 39.5
# [79] 40.0 40.5 41.0 41.5 42.0 42.5 43.0 43.5 44.0 44.5 45.0 45.5 46.0 46.5 47.0 47.5 48.0 48.5 49.0 49.5 50.0 50.5
Using this approach for a vector with 500000 entries fills up my memory within seconds and renders my PC unusable. Alternatively, I've tried using roll_mean from RcppRoll, but wasn't able to come up with a solution because RcppRoll::roll_mean only accepts integers as window lengths.
So, what is the best approach to solve this problem on a large scale? Any help is greatly appreciated.
We can do
cumsum(x) / seq_along(x)
# [1] 1.0 1.5 2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5 6.0 6.5 7.0 7.5 8.0 8.5 9.0 9.5 10.0 10.5
# [21] 11.0 11.5 12.0 12.5 13.0 13.5 14.0 14.5 15.0 15.5 16.0 16.5 17.0 17.5 18.0 18.5 19.0 19.5 20.0 20.5
# [41] 21.0 21.5 22.0 22.5 23.0 23.5 24.0 24.5 25.0 25.5 26.0 26.5 27.0 27.5 28.0 28.5 29.0 29.5 30.0 30.5
# [61] 31.0 31.5 32.0 32.5 33.0 33.5 34.0 34.5 35.0 35.5 36.0 36.5 37.0 37.5 38.0 38.5 39.0 39.5 40.0 40.5
# [81] 41.0 41.5 42.0 42.5 43.0 43.5 44.0 44.5 45.0 45.5 46.0 46.5 47.0 47.5 48.0 48.5 49.0 49.5 50.0 50.5
We can use cummean
library(dplyr)
cummean(x)
#[1] 1.0 1.5 2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5 6.0 6.5 7.0 7.5 8.0 8.5 9.0 9.5 10.0
#[20] 10.5 11.0 11.5 12.0 12.5 13.0 13.5 14.0 14.5 15.0 15.5 16.0 16.5 17.0 17.5 18.0 18.5 19.0 19.5
#[39] 20.0 20.5 21.0 21.5 22.0 22.5 23.0 23.5 24.0 24.5 25.0 25.5 26.0 26.5 27.0 27.5 28.0 28.5 29.0
#[58] 29.5 30.0 30.5 31.0 31.5 32.0 32.5 33.0 33.5 34.0 34.5 35.0 35.5 36.0 36.5 37.0 37.5 38.0 38.5
#[77] 39.0 39.5 40.0 40.5 41.0 41.5 42.0 42.5 43.0 43.5 44.0 44.5 45.0 45.5 46.0 46.5 47.0 47.5 48.0
#[96] 48.5 49.0 49.5 50.0 50.5
I have an svg and in in there are 2 paths
<path d="M 84.4 53.2 C 75.3 50.1 67.1 48.5 59.6 48.3 C 51.2 48 45.2 47.5 41.5 46.5 C 35.7 45.1 29.9 42.4 23.9 38.4 C 21.6 36.9 19.4 35.2 17.3 33.2 C 19.4 34.2 21.6 35 23.9 35.6 C 27.3 36.5 34.1 37 44.1 37.2 C 53.7 37.3 59.7 37.7 62 38.3 C 70.4 40.3 77 44.2 81.8 49.9 C 82.9 51 83.7 52 84.4 53.2 Z" class="st0" style="fill: rgb(15, 141, 225);"/>
<path d="M 68.1 7.3 C 79.5 10.1 86.8 16 89.9 24.9 C 91.4 29.2 91.4 36.1 89.8 45.7 C 89.9 45.8 90 46 90.1 46.2 L 90 46 C 90.4 46.7 90.8 47.4 91.2 48.2 C 93.2 52 94.4 56.2 95 60.7 C 95.1 61.3 95 61.8 94.6 62.3 C 94.2 62.7 93.8 63 93.2 63.1 C 92.7 63.2 92.1 63 91.6 62.7 C 91.2 62.3 90.9 61.9 90.8 61.3 C 90.3 57.3 89.2 53.6 87.5 50.2 C 86.8 49.1 86 48.1 85.1 47.1 C 79.7 40.8 72.4 36.5 63.1 34.2 L 63.2 34.3 C 60.8 33.607 54.5 33.599 44.3 33.1 C 34.709 32.63 28.3 32.4 25.1 31.6 L 25 31.6 C 18.9 30.1 14.1 26.9 10.6 22 C 10.2 21.4 9.8 20.7 9.5 20.1 C 9.5 20.1 9.5 20 9.4 20 C 9.3 19.8 9.2 19.6 9 19.3 C 6.6 15.3 5.3 10.8 5 6.1 C 7.4 8.5 10.3 10.1 13.5 10.9 C 17.7 11.9 22.3 12.1 27.3 11.5 C 30.2 11.2 34.7 10.4 40.6 9 C 46.4 7.5 50.9 6.6 54 6.4 C 59 5.8 63.7 6.1 68.1 7.3 Z" class="st0" style="fill: rgb(11, 59, 91);"/>
Is is possible to select and fill the paths individually with css?
This works
.svg-fill {
fill: red
}
but it fills the whole svg. How can I target the individual paths?
Use nth-child selector:
svg path:nth-child(1) { /*OR svg path:first-child OR svg path:nth-of-type(1)*/
fill:red;
}
svg path:nth-child(2) { /*OR svg path:last-child OR svg path:nth-of-type(2)*/
fill:green;
}
<svg>
<path d="M 84.4 53.2 C 75.3 50.1 67.1 48.5 59.6 48.3 C 51.2 48 45.2 47.5 41.5 46.5 C 35.7 45.1 29.9 42.4 23.9 38.4 C 21.6 36.9 19.4 35.2 17.3 33.2 C 19.4 34.2 21.6 35 23.9 35.6 C 27.3 36.5 34.1 37 44.1 37.2 C 53.7 37.3 59.7 37.7 62 38.3 C 70.4 40.3 77 44.2 81.8 49.9 C 82.9 51 83.7 52 84.4 53.2 Z"/>
<path d="M 68.1 7.3 C 79.5 10.1 86.8 16 89.9 24.9 C 91.4 29.2 91.4 36.1 89.8 45.7 C 89.9 45.8 90 46 90.1 46.2 L 90 46 C 90.4 46.7 90.8 47.4 91.2 48.2 C 93.2 52 94.4 56.2 95 60.7 C 95.1 61.3 95 61.8 94.6 62.3 C 94.2 62.7 93.8 63 93.2 63.1 C 92.7 63.2 92.1 63 91.6 62.7 C 91.2 62.3 90.9 61.9 90.8 61.3 C 90.3 57.3 89.2 53.6 87.5 50.2 C 86.8 49.1 86 48.1 85.1 47.1 C 79.7 40.8 72.4 36.5 63.1 34.2 L 63.2 34.3 C 60.8 33.607 54.5 33.599 44.3 33.1 C 34.709 32.63 28.3 32.4 25.1 31.6 L 25 31.6 C 18.9 30.1 14.1 26.9 10.6 22 C 10.2 21.4 9.8 20.7 9.5 20.1 C 9.5 20.1 9.5 20 9.4 20 C 9.3 19.8 9.2 19.6 9 19.3 C 6.6 15.3 5.3 10.8 5 6.1 C 7.4 8.5 10.3 10.1 13.5 10.9 C 17.7 11.9 22.3 12.1 27.3 11.5 C 30.2 11.2 34.7 10.4 40.6 9 C 46.4 7.5 50.9 6.6 54 6.4 C 59 5.8 63.7 6.1 68.1 7.3 Z" />
</svg>
Each of your paths has the same class (at the end of each path you can see it is defined with class="st0" in the code). If you change the class to make each one unique you can target them individually.
For example, change the second one to class="st1" and then the following CSS will make the 1st path red and the 2nd blue:
.st0 { fill: red; }
.st1 { fill: blue; }
If you want to change them using CSS you should also remove the style="fill: rgb(xx, xx, xx);" from each path.