Histograms
It can be useful to plot frequencies as histograms to visualize the spread of our data.
Let's make a histogram of the number of carburetors in our mtcars
dataset using the function hist()
. The first argument of hist()
is vector of values for which the histogram is desired. Following this, we can add arguments to format the graph as necessary. For instance, hist(variable, argument1, argument2)
Diese Übung ist Teil des Kurses
Basic Statistics
Anleitung zur Übung
- In your script, write a code to produce a histogram of the number of carburetors in each car using the variable
carb
of the data setmtcars
. - Make the title of this histogram "Carburetors" by adding the argument
main = "title*"
inside yourhist()
function. - Remember, you can select a specific variable using either
$
or[,]
. If you need to look at your data you can simply entermtcars
into your console, or if you just want to check the variables you can always enterstr(mtcars)
in your console.
Interaktive Übung zum Anfassen
Probieren Sie diese Übung aus, indem Sie diesen Beispielcode ausführen.
# Make a histogram of the carb variable from the mtcars data set. Set the title to "Carburetors"