You need to install the package with install.packages("nycflights13").
While you're at it, I'd also recommend installing gapminder and Lahman as the datasets from these packages are also used in the book. You can install all 3 with a single command: install.packages(c("nycflights13", "gapminder", "Lahman")).