ShinyApp scatterplot displays only one point Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 00:00UTC (8:00pm US/Eastern) Data science time! April 2019 and salary with experience The Ask Question Wizard is Live!Shiny: passing input$var to aes() in ggplot2passing string to ggplot functionControl the size of points in an R scatterplot?Scatterplot with too many pointsdata.table: selecting part of a data set on condition in a custom functionadding overlay of centiles to ggplot in Shiny apphow to calculate the intersection area of two circles in shiny or R codeCreate a ShinyApp to draw scatterplots using ggplotHow can I produce a result with various inputs by machine learning?Rendering correlation scatterplot in ShinyAppHow do I use Crosstalk in Shiny to filter a reactive data table?How to display a different color on each side of range slider in Shiny app? As you slide on either side, color should also be filled automatically

How fail-safe is nr as stop bytes?

Why wasn't DOSKEY integrated with COMMAND.COM?

Converted a Scalar function to a TVF function for parallel execution-Still running in Serial mode

Chinese Seal on silk painting - what does it mean?

Generate an RGB colour grid

How come Sam didn't become Lord of Horn Hill?

Do wooden building fires get hotter than 600°C?

SF book about people trapped in a series of worlds they imagine

What is the appropriate index architecture when forced to implement IsDeleted (soft deletes)?

Why does it sometimes sound good to play a grace note as a lead in to a note in a melody?

How to write the following sign?

Can anything be seen from the center of the Boötes void? How dark would it be?

Maximum summed subsequences with non-adjacent items

Multiple OR (||) Conditions in If Statement

What is a fractional matching?

Why is it faster to reheat something than it is to cook it?

Time to Settle Down!

AppleTVs create a chatty alternate WiFi network

Is grep documentation about ignoring case wrong, since it doesn't ignore case in filenames?

How to install press fit bottom bracket into new frame

ArcGIS Pro Python arcpy.CreatePersonalGDB_management

Why should I vote and accept answers?

How to compare two different files line by line in unix?

What was the first language to use conditional keywords?



ShinyApp scatterplot displays only one point



Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 23, 2019 at 00:00UTC (8:00pm US/Eastern)
Data science time! April 2019 and salary with experience
The Ask Question Wizard is Live!Shiny: passing input$var to aes() in ggplot2passing string to ggplot functionControl the size of points in an R scatterplot?Scatterplot with too many pointsdata.table: selecting part of a data set on condition in a custom functionadding overlay of centiles to ggplot in Shiny apphow to calculate the intersection area of two circles in shiny or R codeCreate a ShinyApp to draw scatterplots using ggplotHow can I produce a result with various inputs by machine learning?Rendering correlation scatterplot in ShinyAppHow do I use Crosstalk in Shiny to filter a reactive data table?How to display a different color on each side of range slider in Shiny app? As you slide on either side, color should also be filled automatically



.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








0















I'm trying to create a Shiny app to create a scatterplot based on the Iris data set. The code generates the app, but displays only a single point on the graph, no matter what settings I choose in the app. Here's the code:



options(warn = -1)
library(shiny)
library(shinythemes)
library(dplyr)
library(readr)
library(ggplot2)
options(warn=0)



# Define UI
ui <- fluidPage(theme = shinytheme("superhero"),
titlePanel("Iris"),
sidebarLayout(
sidebarPanel(

# Select Inputs
selectInput(inputId = "y",
label = "Y-axis:",
choices = c("Sepal.Length", "Sepal.Width", "Petal.Length", "Petal.Width"),
selected = "Sepal.Length"),

selectInput(inputId = "x",
label = "X-axis:",
choices = c("Sepal.Length", "Sepal.Width", "Petal.Length", "Petal.Width"),
selected = "Petal.Length")
),

# Output
mainPanel(
plotOutput(outputId = "scatterplot")
)
)
)

# Define server function
server <- function(input, output)

# Create the scatterplot object the plotOutput function is expecting
output$scatterplot <- renderPlot(
ggplot(data = iris, aes(x = input$x, y = input$y))+
geom_point(aes(color=Species, shape=Species))+
geom_smooth(method="lm")
)


shinyApp(ui=ui, server=server)









share|improve this question

















  • 1





    Possible duplicate of Shiny: passing input$var to aes() in ggplot2

    – camille
    Mar 8 at 21:17

















0















I'm trying to create a Shiny app to create a scatterplot based on the Iris data set. The code generates the app, but displays only a single point on the graph, no matter what settings I choose in the app. Here's the code:



options(warn = -1)
library(shiny)
library(shinythemes)
library(dplyr)
library(readr)
library(ggplot2)
options(warn=0)



# Define UI
ui <- fluidPage(theme = shinytheme("superhero"),
titlePanel("Iris"),
sidebarLayout(
sidebarPanel(

# Select Inputs
selectInput(inputId = "y",
label = "Y-axis:",
choices = c("Sepal.Length", "Sepal.Width", "Petal.Length", "Petal.Width"),
selected = "Sepal.Length"),

selectInput(inputId = "x",
label = "X-axis:",
choices = c("Sepal.Length", "Sepal.Width", "Petal.Length", "Petal.Width"),
selected = "Petal.Length")
),

# Output
mainPanel(
plotOutput(outputId = "scatterplot")
)
)
)

# Define server function
server <- function(input, output)

# Create the scatterplot object the plotOutput function is expecting
output$scatterplot <- renderPlot(
ggplot(data = iris, aes(x = input$x, y = input$y))+
geom_point(aes(color=Species, shape=Species))+
geom_smooth(method="lm")
)


shinyApp(ui=ui, server=server)









share|improve this question

















  • 1





    Possible duplicate of Shiny: passing input$var to aes() in ggplot2

    – camille
    Mar 8 at 21:17













0












0








0








I'm trying to create a Shiny app to create a scatterplot based on the Iris data set. The code generates the app, but displays only a single point on the graph, no matter what settings I choose in the app. Here's the code:



options(warn = -1)
library(shiny)
library(shinythemes)
library(dplyr)
library(readr)
library(ggplot2)
options(warn=0)



# Define UI
ui <- fluidPage(theme = shinytheme("superhero"),
titlePanel("Iris"),
sidebarLayout(
sidebarPanel(

# Select Inputs
selectInput(inputId = "y",
label = "Y-axis:",
choices = c("Sepal.Length", "Sepal.Width", "Petal.Length", "Petal.Width"),
selected = "Sepal.Length"),

selectInput(inputId = "x",
label = "X-axis:",
choices = c("Sepal.Length", "Sepal.Width", "Petal.Length", "Petal.Width"),
selected = "Petal.Length")
),

# Output
mainPanel(
plotOutput(outputId = "scatterplot")
)
)
)

# Define server function
server <- function(input, output)

# Create the scatterplot object the plotOutput function is expecting
output$scatterplot <- renderPlot(
ggplot(data = iris, aes(x = input$x, y = input$y))+
geom_point(aes(color=Species, shape=Species))+
geom_smooth(method="lm")
)


shinyApp(ui=ui, server=server)









share|improve this question














I'm trying to create a Shiny app to create a scatterplot based on the Iris data set. The code generates the app, but displays only a single point on the graph, no matter what settings I choose in the app. Here's the code:



options(warn = -1)
library(shiny)
library(shinythemes)
library(dplyr)
library(readr)
library(ggplot2)
options(warn=0)



# Define UI
ui <- fluidPage(theme = shinytheme("superhero"),
titlePanel("Iris"),
sidebarLayout(
sidebarPanel(

# Select Inputs
selectInput(inputId = "y",
label = "Y-axis:",
choices = c("Sepal.Length", "Sepal.Width", "Petal.Length", "Petal.Width"),
selected = "Sepal.Length"),

selectInput(inputId = "x",
label = "X-axis:",
choices = c("Sepal.Length", "Sepal.Width", "Petal.Length", "Petal.Width"),
selected = "Petal.Length")
),

# Output
mainPanel(
plotOutput(outputId = "scatterplot")
)
)
)

# Define server function
server <- function(input, output)

# Create the scatterplot object the plotOutput function is expecting
output$scatterplot <- renderPlot(
ggplot(data = iris, aes(x = input$x, y = input$y))+
geom_point(aes(color=Species, shape=Species))+
geom_smooth(method="lm")
)


shinyApp(ui=ui, server=server)






r shiny






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Mar 8 at 20:15









Jack HarrisJack Harris

61




61







  • 1





    Possible duplicate of Shiny: passing input$var to aes() in ggplot2

    – camille
    Mar 8 at 21:17












  • 1





    Possible duplicate of Shiny: passing input$var to aes() in ggplot2

    – camille
    Mar 8 at 21:17







1




1





Possible duplicate of Shiny: passing input$var to aes() in ggplot2

– camille
Mar 8 at 21:17





Possible duplicate of Shiny: passing input$var to aes() in ggplot2

– camille
Mar 8 at 21:17












1 Answer
1






active

oldest

votes


















0














it's because your input$x is actually a string. So replace aes() with aes_string() in your ggplot call:



library(ggplot2)

# This doesn't work: aes
ggplot(data = iris, aes(x = "Sepal.Length", y = "Sepal.Width"))+
geom_point(aes(color=Species, shape=Species))+
geom_smooth(method="lm")

# This works : aes_string
ggplot(data = iris, aes_string(x = "Sepal.Length", y = "Sepal.Width"))+
geom_point(aes(color=Species, shape=Species))+
geom_smooth(method="lm")



See: passing string to ggplot function






share|improve this answer























  • That worked! Thanks so much!

    – Jack Harris
    Mar 8 at 21:08











  • Note that aes_string has been deprecated in favor of tidyeval

    – camille
    Mar 8 at 21:10











  • Thanks Camille. How would you use tidyeval in that case ? The only workaround that I found is !!as.name("Sepal.Length") within aes() but there is probably a more convenient solution.

    – Ismail Müller
    Mar 8 at 22:59












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%2f55070411%2fshinyapp-scatterplot-displays-only-one-point%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














it's because your input$x is actually a string. So replace aes() with aes_string() in your ggplot call:



library(ggplot2)

# This doesn't work: aes
ggplot(data = iris, aes(x = "Sepal.Length", y = "Sepal.Width"))+
geom_point(aes(color=Species, shape=Species))+
geom_smooth(method="lm")

# This works : aes_string
ggplot(data = iris, aes_string(x = "Sepal.Length", y = "Sepal.Width"))+
geom_point(aes(color=Species, shape=Species))+
geom_smooth(method="lm")



See: passing string to ggplot function






share|improve this answer























  • That worked! Thanks so much!

    – Jack Harris
    Mar 8 at 21:08











  • Note that aes_string has been deprecated in favor of tidyeval

    – camille
    Mar 8 at 21:10











  • Thanks Camille. How would you use tidyeval in that case ? The only workaround that I found is !!as.name("Sepal.Length") within aes() but there is probably a more convenient solution.

    – Ismail Müller
    Mar 8 at 22:59
















0














it's because your input$x is actually a string. So replace aes() with aes_string() in your ggplot call:



library(ggplot2)

# This doesn't work: aes
ggplot(data = iris, aes(x = "Sepal.Length", y = "Sepal.Width"))+
geom_point(aes(color=Species, shape=Species))+
geom_smooth(method="lm")

# This works : aes_string
ggplot(data = iris, aes_string(x = "Sepal.Length", y = "Sepal.Width"))+
geom_point(aes(color=Species, shape=Species))+
geom_smooth(method="lm")



See: passing string to ggplot function






share|improve this answer























  • That worked! Thanks so much!

    – Jack Harris
    Mar 8 at 21:08











  • Note that aes_string has been deprecated in favor of tidyeval

    – camille
    Mar 8 at 21:10











  • Thanks Camille. How would you use tidyeval in that case ? The only workaround that I found is !!as.name("Sepal.Length") within aes() but there is probably a more convenient solution.

    – Ismail Müller
    Mar 8 at 22:59














0












0








0







it's because your input$x is actually a string. So replace aes() with aes_string() in your ggplot call:



library(ggplot2)

# This doesn't work: aes
ggplot(data = iris, aes(x = "Sepal.Length", y = "Sepal.Width"))+
geom_point(aes(color=Species, shape=Species))+
geom_smooth(method="lm")

# This works : aes_string
ggplot(data = iris, aes_string(x = "Sepal.Length", y = "Sepal.Width"))+
geom_point(aes(color=Species, shape=Species))+
geom_smooth(method="lm")



See: passing string to ggplot function






share|improve this answer













it's because your input$x is actually a string. So replace aes() with aes_string() in your ggplot call:



library(ggplot2)

# This doesn't work: aes
ggplot(data = iris, aes(x = "Sepal.Length", y = "Sepal.Width"))+
geom_point(aes(color=Species, shape=Species))+
geom_smooth(method="lm")

# This works : aes_string
ggplot(data = iris, aes_string(x = "Sepal.Length", y = "Sepal.Width"))+
geom_point(aes(color=Species, shape=Species))+
geom_smooth(method="lm")



See: passing string to ggplot function







share|improve this answer












share|improve this answer



share|improve this answer










answered Mar 8 at 20:22









Ismail MüllerIsmail Müller

1164




1164












  • That worked! Thanks so much!

    – Jack Harris
    Mar 8 at 21:08











  • Note that aes_string has been deprecated in favor of tidyeval

    – camille
    Mar 8 at 21:10











  • Thanks Camille. How would you use tidyeval in that case ? The only workaround that I found is !!as.name("Sepal.Length") within aes() but there is probably a more convenient solution.

    – Ismail Müller
    Mar 8 at 22:59


















  • That worked! Thanks so much!

    – Jack Harris
    Mar 8 at 21:08











  • Note that aes_string has been deprecated in favor of tidyeval

    – camille
    Mar 8 at 21:10











  • Thanks Camille. How would you use tidyeval in that case ? The only workaround that I found is !!as.name("Sepal.Length") within aes() but there is probably a more convenient solution.

    – Ismail Müller
    Mar 8 at 22:59

















That worked! Thanks so much!

– Jack Harris
Mar 8 at 21:08





That worked! Thanks so much!

– Jack Harris
Mar 8 at 21:08













Note that aes_string has been deprecated in favor of tidyeval

– camille
Mar 8 at 21:10





Note that aes_string has been deprecated in favor of tidyeval

– camille
Mar 8 at 21:10













Thanks Camille. How would you use tidyeval in that case ? The only workaround that I found is !!as.name("Sepal.Length") within aes() but there is probably a more convenient solution.

– Ismail Müller
Mar 8 at 22:59






Thanks Camille. How would you use tidyeval in that case ? The only workaround that I found is !!as.name("Sepal.Length") within aes() but there is probably a more convenient solution.

– Ismail Müller
Mar 8 at 22:59




















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%2f55070411%2fshinyapp-scatterplot-displays-only-one-point%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

AWS Lex not identifying response if by a variable The 2019 Stack Overflow Developer Survey Results Are In Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern) The Ask Question Wizard is Live! Data science time! April 2019 and salary with experienceEnforcing custom enumeration in AWS LEX for slot valuesHow to give response based on user response in Amazon Lex?Intercepting AWS Lambda Response to a AWS Lex QueryLex chat bot error: Reached second execution of fulfillment lambda on the same utteranceamazon lex showing invalid responseLambda response send back to Lex slot?Response card in Amazon lexAmazon Lex - Lambda response return HTML to botHow can I solve 424 (Failed Dependency) (python) obtained from Amazon lex?

Алба-Юлія

Захаров Федір Захарович