163k views
3 votes
The square root rule is used by some spreadsheet programs to pick the number of bins. It simply uses the square root of the number of points in the data set. Find the number of bins suggested by this rule for the Daphne data.

1 Answer

3 votes

Answer:

# install.packages ("gridBase")

# install.packages ("gridExtra")

library (gridBase) # load the gridBase package into memory

library (gridExtra) # load the gridExtra package into memory

h2 <- ggplot (Daphne, aes (x = Daphne)) + # Configure ggplot

geom_histogram (bins = 10, color = "gray", fill = "red") + # select geom_histogram

annotate ("text", x = Inf, y = Inf, label = "Containers = 10", hjust = 1.5, vjust = 5) +

xlab ("Peak size in mm") + # x-axis label

ylab ("Number of birds") + # label y axis

ggtitle (titleDaphne) # create the title

h3 <- ggplot (Daphne, aes (x = Daphne)) +

geom_histogram (bins = 25, color = "gray", fill = "red") +

annotate ("text", x = Inf, y = Inf, label = "Containers = 25", hjust = 1.5, vjust = 5) +

xlab ("Peak size in mm") + # x-axis label

ylab ("Number of birds") + # label y axis

ggtitle (titleDaphne) # create the title

h4 <- ggplot (Daphne, aes (x = Daphne)) +

geom_histogram (bins = 100, color = "gray", fill = "red") +

annotate ("text", x = Inf, y = Inf, label = "Containers = 100", hjust = 1.5, vjust = 5) +

xlab ("Peak size in mm") + # x-axis label

ylab ("Number of birds") + # label y axis

ggtitle (titleDaphne) # create the title

grid.arrange (h2, h3, h4) # print everything on the same page

The square root rule is used by some spreadsheet programs to pick the number of bins-example-1
The square root rule is used by some spreadsheet programs to pick the number of bins-example-2
The square root rule is used by some spreadsheet programs to pick the number of bins-example-3
User Arthur Alvim
by
4.4k points