## ----include = FALSE---------------------------------------------------------- knitr::opts_chunk$set( collapse = TRUE, comment = "#>", message = FALSE, warning = FALSE ) ## ----eval = FALSE------------------------------------------------------------- # # From CRAN # install.packages("ddplot") # # # Development version from GitHub # remotes::install_github("feddelegrand7/ddplot") ## ----setup-------------------------------------------------------------------- library(ddplot) ## ----------------------------------------------------------------------------- line_chart(AirPassengers, y = "passengers", title = "Airline passengers, 1949-1960") ## ----------------------------------------------------------------------------- line_chart( EuStockMarkets, transform = "index", title = "European stock indices", subtitle = "Rebased to 100 at the first visible date; zoom in to move the base" ) ## ----------------------------------------------------------------------------- library(dplyr) library(ggplot2) # for the mpg data mpg %>% group_by(manufacturer) %>% summarise(mean_cty = mean(cty)) %>% bar_chart( x = "manufacturer", y = "mean_cty", sort = "descending", fill = "#4269d0", ytitle = "Average city miles per gallon", title = "City fuel economy by manufacturer" ) ## ----------------------------------------------------------------------------- scatter_plot( data = mpg, x = "displ", y = "hwy", col = "#4269d0", size = 4, xtitle = "Engine displacement (litres)", ytitle = "Highway miles per gallon", title = "Bigger engines, fewer miles" ) ## ----eval = FALSE------------------------------------------------------------- # library(shiny) # library(ddplot) # library(r2d3) # # ui <- fluidPage( # # h2("Example ddplot application"), # # selectInput( # inputId = "colors", # label = "Point color", # choices = colors(), # selected = "springgreen3" # ), # # sliderInput( # inputId = "slider", # label = "Point size", # min = 1, # max = 10, # value = 3 # ), # # d3Output("scatter", height = "450px") # ) # # server <- function(input, output) { # output$scatter <- renderD3({ # scatter_plot( # data = iris, # x = "Sepal.Length", # y = "Sepal.Width", # size = input$slider, # col = input$colors # ) # }) # } # # shinyApp(ui = ui, server = server) ## ----eval = FALSE------------------------------------------------------------- # chart <- line_chart(AirPassengers, y = "passengers") # htmlwidgets::saveWidget(chart, "airpassengers.html") .