10.44 Dataset Head and Tail

20180721 Datasets can be very large, with many observations (millions) and many variables (thousands). We can’t be expected to browse through all of the observations and variables. Instead we might review the contents of the dataset using utils::head() and utils::tail() to consider the top six (by default) and the bottom six observations.

# Review the first few observations.

head(ds) %>% print.data.frame()
##         date location min_temp max_temp rainfall evaporation sunshine
## 1 2008-12-01   Albury     13.4     22.9      0.6          NA       NA
## 2 2008-12-02   Albury      7.4     25.1      0.0          NA       NA
## 3 2008-12-03   Albury     12.9     25.7      0.0          NA       NA
## 4 2008-12-04   Albury      9.2     28.0      0.0          NA       NA
## 5 2008-12-05   Albury     17.5     32.3      1.0          NA       NA
## 6 2008-12-06   Albury     14.6     29.7      0.2          NA       NA
##   wind_gust_dir wind_gust_speed wind_dir_9am wind_dir_3pm wind_speed_9am
## 1             W              44            W          WNW             20
## 2           WNW              44          NNW          WSW              4
## 3           WSW              46            W          WSW             19
....
# Review the last few observations.

tail(ds) %>% print.data.frame()
##         date location min_temp max_temp rainfall evaporation sunshine
## 1 2026-01-25    Uluru     29.0     44.1      0.0          NA       NA
## 2 2026-01-26    Uluru     30.0     41.6      0.0          NA       NA
## 3 2026-01-27    Uluru     30.6     41.6      0.0          NA       NA
## 4 2026-01-28    Uluru     30.0     39.4      0.0          NA       NA
## 5 2026-01-29    Uluru     26.8     44.5      0.0          NA       NA
## 6 2026-01-30    Uluru     26.5     42.4      0.4          NA       NA
##   wind_gust_dir wind_gust_speed wind_dir_9am wind_dir_3pm wind_speed_9am
## 1           NNW              50          SSE          ENE              6
## 2             N              50          NNW            N              9
## 3            NW              43           NW            N             20
....

All the time we are building a picture of the data we are looking at. It is beginning to confirm that location has multiple values whilst date does appear to be a sequence for each location.



If you find this curated material useful then you can consider a donation to support it's ongoing availability and give you access to the PDF version of this book. The material has been scoped up by Generative AI without permission or any kind of recompense so do consider a donation if you can afford it. Unlike Generative AI your access to this materials is freely given. Desktop Survival Guides include Data Science, GNU/Linux, and MLHub. Books available on Amazon include Data Mining with Rattle and Essentials of Data Science. Togaware has a 30 year tradition of making popular open source software which includes sold privacy preserving productivity apps, rattle, wajig, and mlhub. Hosted by Togaware, a pioneer of free and open source software since 1984. Copyright © 1995-2022 Graham.Williams@togaware.com Creative Commons Attribution-ShareAlike 4.0