1

I have a set of data named ais. This data set is in the package sn in R. I used the following codes to read this data set:

library(sn)
data(ais)
attach(ais)

This data shows information (such as the gender, sport, height, weight, etc.) of 202 athletics.

I used tapply to draw the histograms of each sport (frequency of heights). My code is as follow:

par(mfrow = c(3, 4))
tapply(Ht,sport,hist) 

The result of the codes are below pics: enter image description here My question is, how can I show/add the title of each sport (the name of the sport) on its corresponding histogram?

Rojer
  • 335
  • 2
  • 9

1 Answers1

1

We can split the data, and use main as the names of the list

lst1 <- with(ais, split(Ht, sport))
par(mfrow = c(3, 4))
Map(function(x, y) hist(x, main = y), lst1, names(lst1))

-output

enter image description here

akrun
  • 874,273
  • 37
  • 540
  • 662