Histograms: Visualizing Distributions
メニューを表示するにはスワイプしてください
A histogram is a graphical representation that organizes a group of numeric data points into user-specified ranges, known as bins. It displays the frequency (count) of data points that fall within each bin, allowing you to quickly see the distribution, shape, and spread of your data.
Histograms are especially useful when you want to understand how your data is distributed across different values. Each bar in a histogram represents a bin, which is a continuous interval of values. The height of each bar shows how many data points fall within that bin — this is called the frequency. You should use a histogram when you want to visualize the distribution of a single numeric variable, such as exam scores, heights, or ages. Histograms help you identify patterns like skewness, modality (number of peaks), and the presence of outliers.
123456789# Sample data: ages of 100 people ages <- c(23, 25, 31, 22, 35, 29, 40, 30, 28, 32, 33, 27, 26, 24, 38, 36, 34, 29, 31, 30, 25, 28, 27, 32, 30, 31, 29, 35, 33, 26, 27, 28, 24, 25, 26, 31, 29, 30, 32, 28, 29, 27, 26, 25, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61) # Create a basic histogram hist(ages, main = "Histogram of Ages", xlab = "Age", ylab = "Frequency")
You can customize your histogram to better suit your data and make it more visually appealing. To change the number of bins (which controls the width of each bar), use the breaks argument in the hist() function. You can also adjust the color of the bars using the col argument. Customizing bins can help reveal more detail or smooth out noise, depending on your needs.
12345678# Histogram with custom bin width and colors hist(ages, breaks = 8, # Set number of bins to 8 col = "skyblue", # Set bar color border = "white", # Set border color main = "Customized Histogram of Ages", xlab = "Age", ylab = "Frequency")
Histograms are best used for visualizing the distribution of a single numeric variable. They help you spot patterns such as skewed distributions, multiple peaks, or outliers. Unlike bar charts, which compare categories, histograms show how data is spread across continuous intervals. Interpreting a histogram lets you quickly assess the central tendency, variability, and overall shape of your data.
1. What does a histogram show about your data?
2. How can you change the number of bins in a histogram?
3. When should you use a histogram instead of a bar chart?
フィードバックありがとうございます!
AIに質問する
AIに質問する
何でも質問するか、提案された質問の1つを試してチャットを始めてください