เริ่มต้นใช้งานเริ่มต้นใช้งานได้ฟรี

ทำให้กราฟรองรับการแสดงผลบนเว็บ

มาลองใช้ ggplotly() กับกราฟที่เราเคยปรับขนาดกันดูครับ

แบบฝึกหัดนี้เป็นส่วนหนึ่งของหลักสูตร

การสร้างแดชบอร์ดด้วย flexdashboard

ดูคอร์ส

คำแนะนำการฝึกหัด

  • ใช้ ggplotly() เพื่อทำให้กราฟ duration_gg ในแผนภูมิ Trip Durations รองรับการแสดงผลบนเว็บ
  • Knit แล้วขยายหน้าต่าง HTML viewer เพื่อดูผลลัพธ์ จากนั้นลองปรับขนาดหน้าต่างแล้วสังเกตว่าเกิดอะไรขึ้น

แบบฝึกหัดเชิงโต้ตอบแบบลงมือทำ

ลองทำแบบฝึกหัดนี้โดยเติมโค้ดตัวอย่างนี้ให้สมบูรณ์

{"my_document.Rmd":"---\ntitle: \"Bike Shares Daily\"\noutput: \n  flexdashboard::flex_dashboard:\n    orientation: columns\n    vertical_layout: fill\n---\n\n```{r setup, include=FALSE}\nlibrary(flexdashboard)\nlibrary(readr)\nlibrary(lubridate)\nlibrary(ggplot2)\nlibrary(tidyverse)\nlibrary(plotly)\n\ntrips_df <- read_csv('https://assets.datacamp.com/production/course_6355/datasets/sanfran_bikeshare_joined_oneday.csv')\n```\n\n\nOverview\n===================================== \n\nColumn {data-width=650}\n-----------------------------------------------------------------------\n\n### Origins\n\n```{r}\n\n```\n\nColumn {data-width=350}\n-----------------------------------------------------------------------\n\n\n### Trips by Start Time\n\n\n### Trip Durations\n\n```{r}\n\nduration_gg <- trips_df %>%\n  mutate(`Trip Duration (min)` = duration_sec / 60) %>%\n  filter(`Trip Duration (min)` <= 60) %>%\n  ggplot(aes(x = `Trip Duration (min)`)) +\n  theme_bw() +\n  geom_histogram(binwidth = 1) +\n  ylab('# Trips')\n\nduration_gg\n\n```\n\n\n"}
แก้ไขและรันโค้ด