R shiny treemap - error ‘range’ not meaningful for factors












0















Greatly appreciate if anyone could assist on this error.
I am new to R and R shiny.
This error appears after adding the treemap into the shiny app code. May I know which of the variable is causing the error: ‘range’ not meaningful for factors.



Also, attached the screenshot of the tm data. Range is NA.



Any help or comment will be greatly appreciated.



enter image description here



library(shiny)    # for shiny apps
library(leaflet) # renderLeaflet function
library(ggplot2)
library(plotly)


server = function(input, output) {


Cookedfood_R <- readRDS("~/hawkermaster.rds")
linechart <- readRDS("~/line.rds")
linechart2 <- readRDS("~/linechart2.rds")
exploratory <- readRDS("~/exploratory.rds")
tm <- readRDS("~/tm.rds")

#getColor <- function(Cookedfood_R) {
# sapply(Cookedfood_R$TYPE, function(TYPE) {
# if(TYPE == 1) {"blue"}
# else {"orange"} })
#}
icons <- awesomeIcons(
icon = 'ion-close',
iconColor = 'black',
library = 'ion'
#markerColor = getColor(Cookedfood_R)
)

output$map = renderLeaflet({
leaflet() %>% addTiles() %>%
addMarkers(data = Cookedfood_R,
lat = ~ LATITUDE,
lng = ~ LONGITUDE,
icon = icons,
layerId =~HAWKER,
popup = paste(Cookedfood_R$HAWKER, "<br>",
"No. of cooked food stalls:", Cookedfood_R$Cook, "<br>",
"No. of Market stalls:", Cookedfood_R$market,"<br>"))})


# generate data in reactive
ggplot_data <- reactive({
site <- input$map_marker_click$id
linechart[linechart$NEWNAME %in% site,]
})
ggplot_data2 <- reactive({
site <- input$map_marker_click$id
linechart2[linechart2$NEWNAME %in% site,]
})

output$plot <- renderPlotly({
ggplotly(
ggplot(data = ggplot_data(), aes(x = YEAR, y = AVGSQM, color = TYPE))+
geom_line()+theme_bw())
#geom_point(aes(shape=TYPE, size=1))

})
output$plot2 <- renderPlotly({
ggplotly(
ggplot(data = ggplot_data2(), aes(x = YEAR, y = AVG, color = TYPE))+
geom_line()+theme_bw())
#geom_point(aes(shape=TYPE, size=1))

})
output$plot3 <- renderPlotly({
plot_ly(exploratory, x = ~TYPE_OF_STALL, y = ~AVERAGE_BID_PRICE, type = "box", text = rownames(exploratory),
hoverinfo = 'text',
mode = 'markers',
transforms = list(
list(
type = 'filter',
target = 'HAWKER_CENTRE',
operation = '>',
value = unique(exploratory$HAWKER_CENTRE)
)))
})
output$plot4 <- renderPlotly({
plot_ly(Main, y = ~BID_PRICE_PER_SQM, x = ~AGE_OF_HAWKER, color = ~TYPE_OF_STALL, type= "scatter")
})

output$plot5 <- renderHighchart({
tm<- treemap(
tm
,index=c("TYPE_OF_STALL","TRADE")
,vSize="avg_sqm"
,vColor = "TYPE_OF_STALL"
,type="value"
, title = "Treemap of Bid Price Per Sqm Across Trade")

hctreemap(tm, allowDrillToNode = TRUE) %>%
hc_title(text = "Treemap of Bid Price Per Sqm Across Trade") %>%
hc_tooltip(pointFormat = "<b>{point.name}</b>:<br>
Bid Price Per SQM: {point.value:,.0f}") %>%
hc_exporting(enabled = TRUE) # enable export
})

}

ui <- fluidPage(
titlePanel("Visualising Hawkers in Singapore"),
tabsetPanel(
tabPanel("Map", column(8,leafletOutput("map", height="900px")),column(4,br(),br(), plotlyOutput("plot", height="400px")),column(4,br(),br(),plotlyOutput("plot2", height="400px"))),
tabPanel("Exploratory", column(6,br(),br(), plotlyOutput("plot3", height="400px")), column(6,br(),br(), plotlyOutput("plot4", height="400px")), column(6,br(),br(), plotlyOutput("plot5", height="400px")))),
br()
)

shinyApp(ui = ui, server = server)









share|improve this question


















  • 1





    Please read (1) how do I ask a good question, (2) how to create a MCVE as well as (3) how to provide a minimal reproducible example in R. Then edit and improve your question accordingly. I.e., abstract from your real problem... And please dput a sample of your data.

    – Christoph
    Nov 21 '18 at 15:33
















0















Greatly appreciate if anyone could assist on this error.
I am new to R and R shiny.
This error appears after adding the treemap into the shiny app code. May I know which of the variable is causing the error: ‘range’ not meaningful for factors.



Also, attached the screenshot of the tm data. Range is NA.



Any help or comment will be greatly appreciated.



enter image description here



library(shiny)    # for shiny apps
library(leaflet) # renderLeaflet function
library(ggplot2)
library(plotly)


server = function(input, output) {


Cookedfood_R <- readRDS("~/hawkermaster.rds")
linechart <- readRDS("~/line.rds")
linechart2 <- readRDS("~/linechart2.rds")
exploratory <- readRDS("~/exploratory.rds")
tm <- readRDS("~/tm.rds")

#getColor <- function(Cookedfood_R) {
# sapply(Cookedfood_R$TYPE, function(TYPE) {
# if(TYPE == 1) {"blue"}
# else {"orange"} })
#}
icons <- awesomeIcons(
icon = 'ion-close',
iconColor = 'black',
library = 'ion'
#markerColor = getColor(Cookedfood_R)
)

output$map = renderLeaflet({
leaflet() %>% addTiles() %>%
addMarkers(data = Cookedfood_R,
lat = ~ LATITUDE,
lng = ~ LONGITUDE,
icon = icons,
layerId =~HAWKER,
popup = paste(Cookedfood_R$HAWKER, "<br>",
"No. of cooked food stalls:", Cookedfood_R$Cook, "<br>",
"No. of Market stalls:", Cookedfood_R$market,"<br>"))})


# generate data in reactive
ggplot_data <- reactive({
site <- input$map_marker_click$id
linechart[linechart$NEWNAME %in% site,]
})
ggplot_data2 <- reactive({
site <- input$map_marker_click$id
linechart2[linechart2$NEWNAME %in% site,]
})

output$plot <- renderPlotly({
ggplotly(
ggplot(data = ggplot_data(), aes(x = YEAR, y = AVGSQM, color = TYPE))+
geom_line()+theme_bw())
#geom_point(aes(shape=TYPE, size=1))

})
output$plot2 <- renderPlotly({
ggplotly(
ggplot(data = ggplot_data2(), aes(x = YEAR, y = AVG, color = TYPE))+
geom_line()+theme_bw())
#geom_point(aes(shape=TYPE, size=1))

})
output$plot3 <- renderPlotly({
plot_ly(exploratory, x = ~TYPE_OF_STALL, y = ~AVERAGE_BID_PRICE, type = "box", text = rownames(exploratory),
hoverinfo = 'text',
mode = 'markers',
transforms = list(
list(
type = 'filter',
target = 'HAWKER_CENTRE',
operation = '>',
value = unique(exploratory$HAWKER_CENTRE)
)))
})
output$plot4 <- renderPlotly({
plot_ly(Main, y = ~BID_PRICE_PER_SQM, x = ~AGE_OF_HAWKER, color = ~TYPE_OF_STALL, type= "scatter")
})

output$plot5 <- renderHighchart({
tm<- treemap(
tm
,index=c("TYPE_OF_STALL","TRADE")
,vSize="avg_sqm"
,vColor = "TYPE_OF_STALL"
,type="value"
, title = "Treemap of Bid Price Per Sqm Across Trade")

hctreemap(tm, allowDrillToNode = TRUE) %>%
hc_title(text = "Treemap of Bid Price Per Sqm Across Trade") %>%
hc_tooltip(pointFormat = "<b>{point.name}</b>:<br>
Bid Price Per SQM: {point.value:,.0f}") %>%
hc_exporting(enabled = TRUE) # enable export
})

}

ui <- fluidPage(
titlePanel("Visualising Hawkers in Singapore"),
tabsetPanel(
tabPanel("Map", column(8,leafletOutput("map", height="900px")),column(4,br(),br(), plotlyOutput("plot", height="400px")),column(4,br(),br(),plotlyOutput("plot2", height="400px"))),
tabPanel("Exploratory", column(6,br(),br(), plotlyOutput("plot3", height="400px")), column(6,br(),br(), plotlyOutput("plot4", height="400px")), column(6,br(),br(), plotlyOutput("plot5", height="400px")))),
br()
)

shinyApp(ui = ui, server = server)









share|improve this question


















  • 1





    Please read (1) how do I ask a good question, (2) how to create a MCVE as well as (3) how to provide a minimal reproducible example in R. Then edit and improve your question accordingly. I.e., abstract from your real problem... And please dput a sample of your data.

    – Christoph
    Nov 21 '18 at 15:33














0












0








0








Greatly appreciate if anyone could assist on this error.
I am new to R and R shiny.
This error appears after adding the treemap into the shiny app code. May I know which of the variable is causing the error: ‘range’ not meaningful for factors.



Also, attached the screenshot of the tm data. Range is NA.



Any help or comment will be greatly appreciated.



enter image description here



library(shiny)    # for shiny apps
library(leaflet) # renderLeaflet function
library(ggplot2)
library(plotly)


server = function(input, output) {


Cookedfood_R <- readRDS("~/hawkermaster.rds")
linechart <- readRDS("~/line.rds")
linechart2 <- readRDS("~/linechart2.rds")
exploratory <- readRDS("~/exploratory.rds")
tm <- readRDS("~/tm.rds")

#getColor <- function(Cookedfood_R) {
# sapply(Cookedfood_R$TYPE, function(TYPE) {
# if(TYPE == 1) {"blue"}
# else {"orange"} })
#}
icons <- awesomeIcons(
icon = 'ion-close',
iconColor = 'black',
library = 'ion'
#markerColor = getColor(Cookedfood_R)
)

output$map = renderLeaflet({
leaflet() %>% addTiles() %>%
addMarkers(data = Cookedfood_R,
lat = ~ LATITUDE,
lng = ~ LONGITUDE,
icon = icons,
layerId =~HAWKER,
popup = paste(Cookedfood_R$HAWKER, "<br>",
"No. of cooked food stalls:", Cookedfood_R$Cook, "<br>",
"No. of Market stalls:", Cookedfood_R$market,"<br>"))})


# generate data in reactive
ggplot_data <- reactive({
site <- input$map_marker_click$id
linechart[linechart$NEWNAME %in% site,]
})
ggplot_data2 <- reactive({
site <- input$map_marker_click$id
linechart2[linechart2$NEWNAME %in% site,]
})

output$plot <- renderPlotly({
ggplotly(
ggplot(data = ggplot_data(), aes(x = YEAR, y = AVGSQM, color = TYPE))+
geom_line()+theme_bw())
#geom_point(aes(shape=TYPE, size=1))

})
output$plot2 <- renderPlotly({
ggplotly(
ggplot(data = ggplot_data2(), aes(x = YEAR, y = AVG, color = TYPE))+
geom_line()+theme_bw())
#geom_point(aes(shape=TYPE, size=1))

})
output$plot3 <- renderPlotly({
plot_ly(exploratory, x = ~TYPE_OF_STALL, y = ~AVERAGE_BID_PRICE, type = "box", text = rownames(exploratory),
hoverinfo = 'text',
mode = 'markers',
transforms = list(
list(
type = 'filter',
target = 'HAWKER_CENTRE',
operation = '>',
value = unique(exploratory$HAWKER_CENTRE)
)))
})
output$plot4 <- renderPlotly({
plot_ly(Main, y = ~BID_PRICE_PER_SQM, x = ~AGE_OF_HAWKER, color = ~TYPE_OF_STALL, type= "scatter")
})

output$plot5 <- renderHighchart({
tm<- treemap(
tm
,index=c("TYPE_OF_STALL","TRADE")
,vSize="avg_sqm"
,vColor = "TYPE_OF_STALL"
,type="value"
, title = "Treemap of Bid Price Per Sqm Across Trade")

hctreemap(tm, allowDrillToNode = TRUE) %>%
hc_title(text = "Treemap of Bid Price Per Sqm Across Trade") %>%
hc_tooltip(pointFormat = "<b>{point.name}</b>:<br>
Bid Price Per SQM: {point.value:,.0f}") %>%
hc_exporting(enabled = TRUE) # enable export
})

}

ui <- fluidPage(
titlePanel("Visualising Hawkers in Singapore"),
tabsetPanel(
tabPanel("Map", column(8,leafletOutput("map", height="900px")),column(4,br(),br(), plotlyOutput("plot", height="400px")),column(4,br(),br(),plotlyOutput("plot2", height="400px"))),
tabPanel("Exploratory", column(6,br(),br(), plotlyOutput("plot3", height="400px")), column(6,br(),br(), plotlyOutput("plot4", height="400px")), column(6,br(),br(), plotlyOutput("plot5", height="400px")))),
br()
)

shinyApp(ui = ui, server = server)









share|improve this question














Greatly appreciate if anyone could assist on this error.
I am new to R and R shiny.
This error appears after adding the treemap into the shiny app code. May I know which of the variable is causing the error: ‘range’ not meaningful for factors.



Also, attached the screenshot of the tm data. Range is NA.



Any help or comment will be greatly appreciated.



enter image description here



library(shiny)    # for shiny apps
library(leaflet) # renderLeaflet function
library(ggplot2)
library(plotly)


server = function(input, output) {


Cookedfood_R <- readRDS("~/hawkermaster.rds")
linechart <- readRDS("~/line.rds")
linechart2 <- readRDS("~/linechart2.rds")
exploratory <- readRDS("~/exploratory.rds")
tm <- readRDS("~/tm.rds")

#getColor <- function(Cookedfood_R) {
# sapply(Cookedfood_R$TYPE, function(TYPE) {
# if(TYPE == 1) {"blue"}
# else {"orange"} })
#}
icons <- awesomeIcons(
icon = 'ion-close',
iconColor = 'black',
library = 'ion'
#markerColor = getColor(Cookedfood_R)
)

output$map = renderLeaflet({
leaflet() %>% addTiles() %>%
addMarkers(data = Cookedfood_R,
lat = ~ LATITUDE,
lng = ~ LONGITUDE,
icon = icons,
layerId =~HAWKER,
popup = paste(Cookedfood_R$HAWKER, "<br>",
"No. of cooked food stalls:", Cookedfood_R$Cook, "<br>",
"No. of Market stalls:", Cookedfood_R$market,"<br>"))})


# generate data in reactive
ggplot_data <- reactive({
site <- input$map_marker_click$id
linechart[linechart$NEWNAME %in% site,]
})
ggplot_data2 <- reactive({
site <- input$map_marker_click$id
linechart2[linechart2$NEWNAME %in% site,]
})

output$plot <- renderPlotly({
ggplotly(
ggplot(data = ggplot_data(), aes(x = YEAR, y = AVGSQM, color = TYPE))+
geom_line()+theme_bw())
#geom_point(aes(shape=TYPE, size=1))

})
output$plot2 <- renderPlotly({
ggplotly(
ggplot(data = ggplot_data2(), aes(x = YEAR, y = AVG, color = TYPE))+
geom_line()+theme_bw())
#geom_point(aes(shape=TYPE, size=1))

})
output$plot3 <- renderPlotly({
plot_ly(exploratory, x = ~TYPE_OF_STALL, y = ~AVERAGE_BID_PRICE, type = "box", text = rownames(exploratory),
hoverinfo = 'text',
mode = 'markers',
transforms = list(
list(
type = 'filter',
target = 'HAWKER_CENTRE',
operation = '>',
value = unique(exploratory$HAWKER_CENTRE)
)))
})
output$plot4 <- renderPlotly({
plot_ly(Main, y = ~BID_PRICE_PER_SQM, x = ~AGE_OF_HAWKER, color = ~TYPE_OF_STALL, type= "scatter")
})

output$plot5 <- renderHighchart({
tm<- treemap(
tm
,index=c("TYPE_OF_STALL","TRADE")
,vSize="avg_sqm"
,vColor = "TYPE_OF_STALL"
,type="value"
, title = "Treemap of Bid Price Per Sqm Across Trade")

hctreemap(tm, allowDrillToNode = TRUE) %>%
hc_title(text = "Treemap of Bid Price Per Sqm Across Trade") %>%
hc_tooltip(pointFormat = "<b>{point.name}</b>:<br>
Bid Price Per SQM: {point.value:,.0f}") %>%
hc_exporting(enabled = TRUE) # enable export
})

}

ui <- fluidPage(
titlePanel("Visualising Hawkers in Singapore"),
tabsetPanel(
tabPanel("Map", column(8,leafletOutput("map", height="900px")),column(4,br(),br(), plotlyOutput("plot", height="400px")),column(4,br(),br(),plotlyOutput("plot2", height="400px"))),
tabPanel("Exploratory", column(6,br(),br(), plotlyOutput("plot3", height="400px")), column(6,br(),br(), plotlyOutput("plot4", height="400px")), column(6,br(),br(), plotlyOutput("plot5", height="400px")))),
br()
)

shinyApp(ui = ui, server = server)






r shiny range treemap factors






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 21 '18 at 15:09









JoyceJoyce

12




12








  • 1





    Please read (1) how do I ask a good question, (2) how to create a MCVE as well as (3) how to provide a minimal reproducible example in R. Then edit and improve your question accordingly. I.e., abstract from your real problem... And please dput a sample of your data.

    – Christoph
    Nov 21 '18 at 15:33














  • 1





    Please read (1) how do I ask a good question, (2) how to create a MCVE as well as (3) how to provide a minimal reproducible example in R. Then edit and improve your question accordingly. I.e., abstract from your real problem... And please dput a sample of your data.

    – Christoph
    Nov 21 '18 at 15:33








1




1





Please read (1) how do I ask a good question, (2) how to create a MCVE as well as (3) how to provide a minimal reproducible example in R. Then edit and improve your question accordingly. I.e., abstract from your real problem... And please dput a sample of your data.

– Christoph
Nov 21 '18 at 15:33





Please read (1) how do I ask a good question, (2) how to create a MCVE as well as (3) how to provide a minimal reproducible example in R. Then edit and improve your question accordingly. I.e., abstract from your real problem... And please dput a sample of your data.

– Christoph
Nov 21 '18 at 15:33












0






active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53415002%2fr-shiny-treemap-error-range-not-meaningful-for-factors%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53415002%2fr-shiny-treemap-error-range-not-meaningful-for-factors%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

How to change which sound is reproduced for terminal bell?

Title Spacing in Bjornstrup Chapter, Removing Chapter Number From Contents

Can I use Tabulator js library in my java Spring + Thymeleaf project?