A Question About Histograms

How do you add a title to a histogram of a dataset? Any assistance is greatly appreciated in this matter.

Here is my code:
hist(county, main="Skewness of Dataset: County")

Here is the output (notice there is not title in the output):

Sample dataset:

MedianListPrice ActiveListCount MedianDom NewListing Count PriceIncreaseCount PriceReducedCount PendingListCount MedianPpsf MedianSqFt AvgListPrice TotalListCount
364945 1950 37 908 52 1036 51 171 2256 455053 2001
401950 1227 36 772 60 736 922 163 2571 440090 2149
139900 292 61 68 4 76 3 89 1621 173321 295
233900 383 67 100 12 116 23 121 1891 271728 406
239990 1021 94 204 72 164 4 104 2300 344596 1025
249900 1067 80 248 16 272 13 133 1868 318950 1080
245000 887 64 404 48 228 107 110 2092 272750 994
817754 2131 29 1472 68 756 1358 542 1501 981660 3489
269900 1125 81 316 4 308 594 148 1800 332820 1719
504945 628 114 136 8 88 319 183 2725 819756 947
639250 445 36 220 16 184 163 375 1535 798905 608
113950 424 114 72 4 104 9 68 1658 134915 433
186700 922 39 464 12 412 2 88 1990 262489 924
219450 288 66 104 4 80 149 99 2071 261439 437
189000 375 62 100 4 136 69 112 1707 218547 444
424995 1906 82 648 68 508 260 194 2106 540930 2166
368137 467 50 276 4 112 387 159 2167 387759 854
435068 1092 46 820 48 404 869 181 2477 624755 1961
837000 214 75 156 4 36 78 367 1698 1024109 292
274462 682 93 200 8 160 13 134 2051 302002 695
244999 2450 100 728 28 364 74 76 991 413659 2524
329077 3170 105 840 72 672 1 151 1961 429301 3171
167900 2786 75 960 56 756 255 112 1301 215087 3041
269950 1890 72 700 40 580 287 151 1728 368524 2177
212250 212 76 108 4 44 5 97 2278 262975 217
550000 2953 109 740 20 416 270 321 1808 950955 3223
260000 727 88 272 60 128 355 99 2000 343824 1082
244900 802 76 284 40 148 324 96 1650 353612 1126
279950 264 88 92 12 76 64 142 2002 338213 328
319950 1759 106 536 80 236 2 215 1506 411251 1761
426950 2838 112 640 32 548 791 199 2157 644477 3629
235900 849 148 164 4 96 207 105 1544 344713 1056
220000 1111 73 428 12 188 548 102 2130 250142 1659
290000 1582 85 464 32 320 609 121 2343 367288 2191
334900 667 68 196 20 120 4 162 2115 361361 671
283324 687 78 316 32 204 246 136 2193 425106 933
227950 580 92 148 12 84 98 115 1867 240743 678
206125 1108 92 356 20 216 25 105 1810 256895 1133
374950 853 140 120 4 68 171 184 2000 622974 1024

See the FAQ: How to do a minimal reproducible example reprex for beginners.

hist(mtcars$mpg, 
main = "Distribution of mileage in the mtcars dataset",
     xlab = "Miles per gallon")

This suggests that the problem arises from however the output of multiple histograms is being generated.

I did not put my dataset up because there are 6000 data points, and the last time I put a sample, someone complained. How much of the dataset should I put up as a reprex?

It doesn't have to be all your data, your data at all if there is another data set available in an R package or otherwise, or even real data. Just to illustrate how you get to the image.

I posted some of the data.

As a reprex, the data should look like this, produced with

dput(county)

or preferably

county <- data.frame(
  MedianListPrice =
    c(364945, 401950, 139900, 233900, 239990, 249900, 245000, 817754, 269900, 504945, 639250, 113950, 186700, 219450, 189000, 424995, 368137, 435068, 837000, 274462, 244999, 329077, 167900, 269950, 212250, 550000, 260000, 244900, 279950, 319950, 426950, 235900, 220000, 290000, 334900, 283324, 227950, 206125, 374950),
  ActiveListCount =
    c(1950, 1227, 292, 383, 1021, 1067, 887, 2131, 1125, 628, 445, 424, 922, 288, 375, 1906, 467, 1092, 214, 682, 2450, 3170, 2786, 1890, 212, 2953, 727, 802, 264, 1759, 2838, 849, 1111, 1582, 667, 687, 580, 1108, 853),
  MedianDom =
    c(37, 36, 61, 67, 94, 80, 64, 29, 81, 114, 36, 114, 39, 66, 62, 82, 50, 46, 75, 93, 100, 105, 75, 72, 76, 109, 88, 76, 88, 106, 112, 148, 73, 85, 68, 78, 92, 92, 140),
  "NewListing Count" =
    c(908, 772, 68, 100, 204, 248, 404, 1472, 316, 136, 220, 72, 464, 104, 100, 648, 276, 820, 156, 200, 728, 840, 960, 700, 108, 740, 272, 284, 92, 536, 640, 164, 428, 464, 196, 316, 148, 356, 120),
  PriceIncreaseCount =
    c(52, 60, 4, 12, 72, 16, 48, 68, 4, 8, 16, 4, 12, 4, 4, 68, 4, 48, 4, 8, 28, 72, 56, 40, 4, 20, 60, 40, 12, 80, 32, 4, 12, 32, 20, 32, 12, 20, 4),
  PriceReducedCount =
    c(1036, 736, 76, 116, 164, 272, 228, 756, 308, 88, 184, 104, 412, 80, 136, 508, 112, 404, 36, 160, 364, 672, 756, 580, 44, 416, 128, 148, 76, 236, 548, 96, 188, 320, 120, 204, 84, 216, 68),
  PendingListCount =
    c(51, 922, 3, 23, 4, 13, 107, 1358, 594, 319, 163, 9, 2, 149, 69, 260, 387, 869, 78, 13, 74, 1, 255, 287, 5, 270, 355, 324, 64, 2, 791, 207, 548, 609, 4, 246, 98, 25, 171),
  MedianPpsf =
    c(171, 163, 89, 121, 104, 133, 110, 542, 148, 183, 375, 68, 88, 99, 112, 194, 159, 181, 367, 134, 76, 151, 112, 151, 97, 321, 99, 96, 142, 215, 199, 105, 102, 121, 162, 136, 115, 105, 184),
  MedianSqFt =
    c(2256, 2571, 1621, 1891, 2300, 1868, 2092, 1501, 1800, 2725, 1535, 1658, 1990, 2071, 1707, 2106, 2167, 2477, 1698, 2051, 991, 1961, 1301, 1728, 2278, 1808, 2000, 1650, 2002, 1506, 2157, 1544, 2130, 2343, 2115, 2193, 1867, 1810, 2000),
  AvgListPrice =
    c(455053, 440090, 173321, 271728, 344596, 318950, 272750, 981660, 332820, 819756, 798905, 134915, 262489, 261439, 218547, 540930, 387759, 624755, 1024109, 302002, 413659, 429301, 215087, 368524, 262975, 950955, 343824, 353612, 338213, 411251, 644477, 344713, 250142, 367288, 361361, 425106, 240743, 256895, 622974),
  TotalListCount =
    c(2001, 2149, 295, 406, 1025, 1080, 994, 3489, 1719, 947, 608, 433, 924, 437, 444, 2166, 854, 1961, 292, 695, 2524, 3171, 3041, 2177, 217, 3223, 1082, 1126, 328, 1761, 3629, 1056, 1659, 2191, 671, 933, 678, 1133, 1024)
)

So, the next question is how are you producing the output shown from the county data frame with the command hist(county, main = "something")

I input the r code I shared above and it produced the graph shown. The only thing missing from it was the title.

I figured it out.

hist(county)
mtext("Skewness of Dataset: County", side=3, line=3)

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.