library("readr") library("tibble") library("lubridate") library("magrittr") library("vegawidget")
set.seed(314159) n_cat <- 10 data_category <- tibble( category = letters[seq(n_cat)], number = as.integer(runif(n_cat) * 100) ) %>% glimpse()
This data is taken from the vega-datasets repository. For this dataset, the source is NOAA.
data_seattle_daily <- read_csv("https://vega.github.io/vega-datasets/data/seattle-weather.csv")
data_seattle_hourly <- read_csv("https://vega.github.io/vega-datasets/data/seattle-weather-hourly-normals.csv") %>% glimpse() # need to correct one of the times (this instant does not exist in local time) data_seattle_hourly$date[data_seattle_hourly$date == "2010-03-14T02:00:00"] <- "2010-03-14T03:00:00" data_seattle_hourly$date <- parse_date_time( data_seattle_hourly$date, orders = "%Y/%m/%d %H:%M:%S", tz = "America/Los_Angeles" ) data_seattle_hourly$temp <- data_seattle_hourly$temperature data_seattle_hourly <- data_seattle_hourly[, c("date", "temp")]
glimpse(data_seattle_hourly)
The data are documented in R/data.R
.
spec_mtcars <- as_vegaspec( list( `$schema` = "https://vega.github.io/schema/vega-lite/v5.json", width = 300L, height = 300L, description = "An mtcars example.", data = list(values = mtcars), mark = "point", encoding = list( x = list(field = "wt", type = "quantitative"), y = list(field = "mpg", type = "quantitative"), color = list(field = "cyl", type = "nominal") ) ) ) class(spec_mtcars)
usethis::use_data( data_category, data_seattle_daily, data_seattle_hourly, spec_mtcars, overwrite = TRUE )
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.