Input to asJSON(keep_vec_names=TRUE) is a named vector. In a future version of jsonlite, this option will not be supported, and named vectors will be translated into arrays instead of objects. If you want JSON object output, please use a named list instead. See ?toJSON.
This problem happens when I run the plot at the end of the script, and I do not know how to solve it. Help?
library(shiny)
library(ggplot2)
library(caret)
library(shinyPredict)
library(ISLR2)
# Define server logic required to draw a histogram
function(input, output, session) {
datasets <- list(AirPassengers = AirPassengers, CO2 = CO2, Formaldehyde = Formaldehyde, Indometh = Indometh,
LifeCycleSavings = LifeCycleSavings, OrchardSprays = OrchardSprays, Theoph = Theoph,
UKDriverDeaths = UKDriverDeaths, WWWusage = WWWusage, austres = austres,chickwts = chickwts,
esoph = esoph, faithful = faithful, islands = islands, lynx = lynx, nhtemp = nhtemp, precip = precip, randu = randu,
stack.loss = stack.loss, state.area = state.area, state.region = state.region, sunspots = sunspots, BJsales = BJsales,
ChickWeight = ChickWeight, HairEyeColor = HairEyeColor, InsectSprays = InsectSprays, Loblolly = Loblolly, PlantGrowth = PlantGrowth,
Titanic = Titanic, UKgas = UKgas, USPersonalExpenditure = USPersonalExpenditure, WorldPhones = WorldPhones, anscombe = anscombe,
beaver1 = beaver1, co2 = co2, euro = euro, fdeaths = fdeaths, infert = infert, ldeaths = ldeaths, mdeaths = mdeaths,
nottem = nottem, presidenst = presidents, rivers = rivers, stackloss = stackloss, state.center = state.center, state.x77 = state.x77,
swiss = swiss, volcano = volcano, BJsales.lead = BJsales.lead, DNase = DNase, Harman23.cor = Harman23.cor, JohnsonJohnson = JohnsonJohnson,
Nile = Nile, mtcars = mtcars, trees = trees)
#output$pkgs <- renderPrint(.packages(all.available = TRUE))
# output$dat <- renderPrint(data(package = "datasets")$results[ , "Item"])
#print(trees)
ds <- reactive( datasets[[input$inDs]] )
observe(updateVarSelectInput(session, "inVar", data = ds()))
observe(updateVarSelectInput(session, "inVar1", data = ds()))
output$outData <- renderTable({
var_char <- as.character(input$inVar)
# deal with race conditions, input$inVar might still include
# a column name from previously selected dataset
req(var_char %in% names(ds()))
ds()[1:12, var_char, drop = FALSE]
}, align = "l")
output$outData1 <- renderTable({
var_char1 <- as.character(input$inVar1)
# deal with race conditions, input$inVar might still include
# a column name from previously selected dataset
req(var_char1 %in% names(ds()))
ds()[1:12, var_char1, drop = FALSE]
}, align = "l")
output$hist <- renderPlot({ +
ggplot(ds(), aes_string(input$inVar,input$inVar1)) + geom_histogram()
})