I'm trying to find the average of the longest run in 10,000 simulations when flipping a coin 30 times. I need to simulate in R, the experiment described above 10,000 times and each time note the length of the longest run.

Here's my code so far:

```
coin <- sample(c("H", "T"), 10000, replace = TRUE)
table(coin) 
head(coin, n = 30)
rle(c("H", "T", "T", "H", "H", "H", "H", "H", "T", "H"))
coin.rle <- rle(coin)
str(coin.rle)

```

How to find the average of the longest run in 10,000 simulations?
=================================================================