Lab 08: Tibbles and Pipes

Note

In lab.qmd ## Lab 8 section,

  1. Compare and contrast the following operations on a data.frame and equivalent tibble. What are the differences?
df <- data.frame(abc = 1:2, 
                 xyz = c("a", "b"))
# list method
df$x
df[[2]]
df["xyz"]
df[c("abc", "xyz")]
# matrix method
df[, 2]
df[, "xyz"]
df[, c("abc", "xyz")]
tib <- tibble(abc = 1:2, 
              xyz = c("a", "b"))
# list method
tib$x
tib[[2]]
tib["xyz"]
tib[c("abc", "xyz")]
# matrix method
tib[, 2]
tib[, "xyz"]
tib[, c("abc", "xyz")]
  1. Use |> to first select last 12 rows of iris data set using tail(), then provides summary statistics on its columns using summary().