I am afraid I am stuck.
I have a simple Shiny script with the intention of subsetting a dataframe based on user input and plot two variables in a scatterplot. When running the script I always get the error "Error in data.frame(x = c(1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, : arguments imply differing number of rows: 1786, 2731". All I know is this error occurs when data is n_col!=n_row in a dataframe. However, I do not see how this can be the issue here. What buffles me is, if I execute the snippet below , the plot is drawn without problems:
#test4 <- subset(test2, grepl("PLANT1", test2$PLANTS))
#ggplot(test4, aes(x=test4$HOUR, y=test4$PRICE_NO)) +
     geom_point(shape=1)
All I am doing is substituting the string with input$plant from ui.r.
Here is my Main window code:
###################################
# Launch  App
###################################
#install.packages("shiny")
#install.packages("ggplot2")
library(shiny)
library(ggplot2)
#load data
#data <- read.csv2(file="C:/data.csv",head=FALSE)
#test4 <- subset(test2, grepl("PLANT1", test2$PLANTS))
#ggplot(test4, aes(x=test4$HOUR, y=test4$PRICE_NO)) +
     geom_point(shape=1)
runApp("C:/PATH/")
My server.r
library(shiny)
library(ggplot2)
# Define Input to Plot
shinyServer(function(input, output) {
output$distPlot <- renderPlot({
# Draw Plot
test4 <- subset(test2, grepl(input$plant, test2$PLANTS))
ggplot(test4, aes(x=test4$HOUR, y=test4$PRICE_NO)) +
  geom_point(shape=1)
})
})
My ui.r
library(shiny)
# Title
shinyUI(fluidPage(
titlePanel("TITLE"),
#Sidebar Layout
sidebarLayout(
 sidebarPanel(
  textInput("plant",
              label = h3("Plant:"),
              value = "PLANT1")
  ),
#
mainPanel(
  plotOutput("distPlot")
  )
)
))
Sample data as requested:
test2
plants HOUR PRICE
plant1 1    12,45
plant1 2    15,52
plant1 3    15,45
plant1 4    78,12
plant1 5    72,12
plant2 1    78,72
plant2 2    72,52
plant2 3    75,52 
plant2 4    78,11
 
    