attempt to use zero-length variable name

2,900 views
Skip to first unread message

Kavita Rathore

unread,
Mar 1, 2015, 3:08:36 AM3/1/15
to shiny-...@googlegroups.com

clusters<-reactive(function(){

x1<-data()

df <- Y()
df<-df[,c(input$xcolumn_c,input$ycolumn_c)]
kmeans(df,input$clust)
})

output$downloadPlot <- downloadHandler(
filename="abc",
content = function(file) {
pdf(file)
print(clusters())
dev.off()
}

hey...above is my code to download the cluster graph...but it shows the error :attempt to use zero-length variable name

please help me out...please.....

Sigbert Klinke

unread,
Mar 2, 2015, 12:16:23 PM3/2/15
to shiny-...@googlegroups.com
Hi,

just a guess: add a

str(input$xcolumn_c)
str
(input$ycolumn_c)


to your code to see the values. I suspect the reactive function is called when one (or both) input$... is yet not set and then they are NULL.

Best Sigbert

Kavita Rathore

unread,
Mar 3, 2015, 1:28:10 AM3/3/15
to shiny-...@googlegroups.com
hi,

Thank you for repplying.
my code is correctly plotting the clustering graph..it is just not downloading it...i dnt know the reason for the same.

Joe Cheng

unread,
Mar 3, 2015, 10:48:54 AM3/3/15
to Kavita Rathore, shiny-...@googlegroups.com
What version of Shiny are you using? (packageVersion("shiny")) If you're using something older than 0.11.1, can you try upgrading?

--
You received this message because you are subscribed to the Google Groups "Shiny - Web Framework for R" group.
To unsubscribe from this group and stop receiving emails from it, send an email to shiny-discus...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/shiny-discuss/d9d61734-edf8-4d6a-b2c0-d408b97cc547%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Scott Shepard

unread,
May 20, 2015, 4:59:22 PM5/20/15
to shiny-...@googlegroups.com
I don't know if you ever solved this, but I ran into the same issue today and was able to solve it.

I was trying to add a button to download a data table. The table was displaying correctly but I was unable to download it with that error of zero-length variable name.

output$download_table <- downloadHandler(
  filename = "Table.csv",
  content = function(file) {
    write.csv(data_table(), file)
  }
)

My problem was solved when I wrapped the filename in an anonymous function, i.e

output$download_table <- downloadHandler(
  filename = function() "Table.csv",
  content = function(file) {
    write.csv(data_table(), file)
  }
)
Reply all
Reply to author
Forward
0 new messages