Plot an uploaded .txt file

Hello,
I must create an App with many tabs and, in one of the tabs, I must upload a file in .txt and plot an graph (preferably using ggplot2). The table also must show the x and y table, but this is working fine. Here is the .txt file, ui and server code, and the error message I get when I run the App.

The .txt file:
x,y
1,2
2,4
4,8
8,16
16,32

ui:
tabPanel("Plot txt", verbatimTextOutput("plottxt"),
sidebarLayout(
sidebarPanel(
fileInput("file1", "Choose CSV File",
accept = c(
"text/csv",
"text/comma-separated-values,text/plain",
".csv")
),
tags$hr(),
checkboxInput("header", "Header", TRUE)
),
mainPanel(
tableOutput("contents"),
plotOutput("tableplot")
)
)
)

server:
output$contents <- renderTable({
# input$file1 will be NULL initially. After the user selects
# and uploads a file, it will be a data frame with 'name',
# 'size', 'type', and 'datapath' columns. The 'datapath'
# column will contain the local filenames where the data can
# be found.
inFile <- input$file1

if (is.null(inFile))
  return(NULL)

read.csv(inFile$datapath, header = input$header)

})

output$tableplot <- renderPlot({
** inFile <- input$file1**
** plotdados <- read.table(inFile$datapath, header = input$header)**
** ggplot(plotdados, aes(x, y)) + geom_abline()**


** })**

Error:
Warning in pngfun(filename = filename, width = width, height = height, res = res, :
unable to allocate bitmap
Warning in pngfun(filename = filename, width = width, height = height, res = res, :
opening device failed
Warning: Error in pngfun: não é possível iniciar dispositivo png()
127: pngfun
126: startPNG
125: drawPlot
111: reactive:plotObj
95: drawReactive
82: origRenderFunc
81: output$hist
1: runApp

This topic was automatically closed 54 days after the last reply. New replies are no longer allowed.