purrr 中的圖形

使用 purrr 的函式式程式設計基礎

Auriel Fournier

Instructor

ggplot() 複習

  • ggplot() 需要 data frame 輸入
  • 一律從 ggplot() 開始
  • 用 + 新增圖層
  • geom_*() 指定圖形類型
ggplot(data = dataframe, 
       aes(x = columnA,
       y = columnB))+
  geom_point()

鳥類體重與翼長的散佈圖

使用 purrr 的函式式程式設計基礎

繪圖與 purrr

birddf <- bird_measurements %>% 
 map_df(~ data_frame(
            wing_length = .x[["wing length"]],
            weight = .x[["weight"]])) %>%
    ggplot(aes(x = weight,
            y = wing_length))+
    geom_point()

鳥類體重與翼長的散佈圖

使用 purrr 的函式式程式設計基礎

Let's purrr-actice!

使用 purrr 的函式式程式設計基礎

Preparing Video For Download...