MulaiMulai sekarang secara gratis

Static Graph

Now we'll add a graph to our dashboard.

Latihan ini adalah bagian dari kursus

Building Dashboards with flexdashboard

Lihat Kursus

Petunjuk latihan

  • The provided R code chunk static_plot (under the setup chunk) contains code to create a single static plot using ggplot2.
  • Move this code chunk so that it appears as a plot in the Trip Durations chart.
  • Knit and then expand the HTML viewer. Note the sizing of the plot with relation to the size of the chart container. Try resizing the window and observe what happens.

Latihan interaktif praktis

Cobalah latihan ini dengan menyelesaikan kode contoh berikut.

{"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)\n\ntrips_df <- read_csv('https://assets.datacamp.com/production/course_6355/datasets/sanfran_bikeshare_joined_oneday.csv')\n```\n\n```{r static_plot}\n\ntrips_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\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\n"}
Edit dan Jalankan Kode