title: R gWidgets reading, editing and writing data.frame in GUI
body: <p>I'm updating a GUI I created to record and track work progress. At the moment, it allows the user to note what's been said in meetings and on what topic, then save that to a dated XML file. These files are saved in folders marked for different projects.</p>
  
  <p>I want to add a function that allows users to update a csv file of completed tasks. The tasks are all set out in the file, the user just has to select a task to label it as done.</p>
  
  <p>The problem I'm having is that when the submit button is hit, the R session returns an error for the write.table function, saying it can't find the data.frame 'task'.</p>
  
  <p>Is there something I'm getting wrong or do I need to use a completlely different method ?</p>
  
  <pre><code>OS &lt;- Sys.info()['sysname']
  
  if (OS == "Linux") {
  desktop &lt;- list.files(path = ".", pattern = NULL, all.files = FALSE,
             full.names = FALSE, recursive = FALSE,
             ignore.case = FALSE, include.dirs = FALSE, no.. = FALSE)
  
  
  if ("Desktop" %in% desktop)  {
  
  pedantpath &lt;- paste(getwd(), "/Desktop/pedant", sep="")
  }
  
  
  if ("Bureau" %in% desktop) {
  
  pedantpath &lt;- paste(getwd(), "/Bureau/pedant", sep="")
  }
  }
  
  if (OS == "Windows") {
  
  pedantpath &lt;-  paste(Sys.getenv()["USERPROFILE"], "\\Desktop\\pedant", sep="")
  }
  
  library(RGtk2)
  library(cairoDevice)
  library(gWidgets)
  library(gWidgetsRGtk2)
  
  mainwin &lt;- gwindow("Record Master", horizontal = FALSE, visible=TRUE)
  1
  select.button &lt;- gbutton("Select", container=mainwin, handler = function(h,...) {
  selection &lt;- gfile(type = c ("selectdir"))
  
  win &lt;- gwindow("Record Master", horizontal = FALSE, visible=TRUE)
  
  biggestgroup &lt;- ggroup(horizontal = FALSE,  anchor=c(0,-1), container=win)
  tip &lt;- glabel("Welcome. \nPlease use this form to keep your records.", anchor=c(0,0), container=biggestgroup)
  class &lt;- gcombobox(c("A","B","C","D","E","F"), editable=TRUE, expand=TRUE, anchor=c(0,-1), container=biggestgroup)
  
  select.button &lt;- gbutton("Select Task", container=biggestgroup, handler = function(h,...) {
  
  
  tasks &lt;- read.table(paste(selection, "\\task.csv", sep=""), sep=",")
  task &lt;- c(1:30)
  task &lt;- gcombobox(as.character(task$V1), editable=TRUE, expand=TRUE, anchor=c(0,-1), container=biggestgroup)
  taskchoice &lt;- paste(svalue(task), sep="")
  task$V2[which(grepl(as.character(taskchoice), task$V1))] = 1
  })
  
  
  biggergroup &lt;- ggroup(horizontal = TRUE, width = 30,expand=TRUE, container=biggestgroup)
  group &lt;- ggroup(horizontal = FALSE, height = 400, use.scrollwindow = TRUE, expand = TRUE, container = biggergroup)
  group2 &lt;- ggroup(horizontal = FALSE, height = 400, use.scrollwindow = TRUE, expand = TRUE, container = biggergroup)
  group3 &lt;- ggroup(horizontal = FALSE, use.scrollwindow = TRUE, anchor=c(0,1), expand = TRUE, container = biggestgroup)
  
  
  
  # dialogue boxes for the activities
  
  obj.meeting1.label &lt;- gcombobox(c("no_meeting", "research", "purchasing", "progress", "marketing", "accounting", "deployment", "sales"), editable=TRUE, expand=TRUE, container=group)
  meeting1 &lt;- gtext(text = "Insert content", height = 150, expand=TRUE, container=group2)
  
  
  obj.meeting2.label &lt;- gcombobox(c("no_meeting", "research", "purchasing", "progress", "marketing", "accounting", "deployment", "sales"), editable=TRUE, expand=TRUE, container=group)
  meeting2 &lt;- gtext("Insert content",  height = 15, expand=TRUE, container=group2)
  
  
  obj.meeting3.label &lt;- gcombobox(c("no_meeting", "research", "purchasing", "progress", "marketing", "accounting", "deployment", "sales"), editable=TRUE, expand=TRUE, container=group)
  meeting3 &lt;- gtext(text = "Insert content", height = 300, expand=TRUE, container=group2)
  
  
  obj.meeting4.label &lt;- gcombobox(c("no_meeting", "research", "purchasing", "progress", "marketing", "accounting", "deployment", "sales"), editable=TRUE, expand=TRUE, container=group)
  meeting4 &lt;- gtext("Insert content", expand=TRUE, container=group2)
  
  
  obj.meeting5.label &lt;- gcombobox(c("no_meeting", "research", "purchasing", "progress", "marketing", "accounting", "deployment", "sales"), editable=TRUE, expand=TRUE, container=group)
  
  
  meeting5 &lt;- gtext("Insert content", expand=TRUE, container=group2)
  
  submitbutton &lt;- gbutton("Submit", container=group3, handler = function(h,...) {
  starttag1 &lt;- paste("&lt;", svalue(obj.meeting1.label), "&gt;", sep="")
  starttag1 &lt;- gsub(" ", "_", starttag1)
  endtag1 &lt;- paste("&lt;/", svalue(obj.meeting1.label), "&gt;", sep="")
  endtag1 &lt;- gsub(" ", "_", endtag1)
  
  starttag2 &lt;- paste("&lt;", svalue(obj.meeting2.label), "&gt;", sep="")
  starttag2 &lt;- paste("&lt;", svalue(obj.meeting2.label), "&gt;", sep="")
  endtag2 &lt;- paste("&lt;/", svalue(obj.meeting2.label), "&gt;", sep="")
  endtag2 &lt;- gsub(" ", "_", endtag2)
  
  starttag3 &lt;- paste("&lt;", svalue(obj.meeting3.label), "&gt;", sep="")
  starttag3 &lt;- paste("&lt;", svalue(obj.meeting3.label), "&gt;", sep="")
  endtag3 &lt;- paste("&lt;/", svalue(obj.meeting3.label), "&gt;", sep="")
  endtag3 &lt;- gsub(" ", "_", endtag3)
  
  starttag4 &lt;- paste("&lt;", svalue(obj.meeting4.label), "&gt;", sep="")
  starttag4 &lt;- paste("&lt;", svalue(obj.meeting4.label), "&gt;", sep="")
  endtag4 &lt;- paste("&lt;/", svalue(obj.meeting4.label), "&gt;", sep="")
  endtag4 &lt;- gsub(" ", "_", endtag4)
  
  starttag5 &lt;- paste("&lt;", svalue(obj.meeting5.label), "&gt;", sep="")
  starttag5 &lt;- paste("&lt;", svalue(obj.meeting5.label), "&gt;", sep="")
  endtag5 &lt;- paste("&lt;/", svalue(obj.meeting5.label), "&gt;", sep="")
  endtag5 &lt;- gsub(" ", "_", endtag5)
  
  report &lt;- c("&lt;?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\" ?&gt;",
  "&lt;report&gt;", starttag1, svalue(meeting1), endtag1, starttag2, svalue(meeting2), endtag2, starttag3, svalue(meeting3), endtag3, starttag4, svalue(meeting4), endtag4, starttag5, svalue(meeting5), endtag5, "&lt;/report&gt;")
  
  OS &lt;- Sys.info()['sysname']
  
  if (OS == "Linux") {
  write.table(report, file=paste(selection, "/", Sys.Date(), ".xml", sep=""), sep="\n", row.names=FALSE, col.names=FALSE, quote=FALSE, append=TRUE)
  
  }
  
  if (OS == "Windows") {
  write.table(report, file=paste(selection, "\\", Sys.Date(), ".xml", sep=""), sep="\n", row.names=FALSE, col.names=FALSE, quote=FALSE, append=TRUE)
  write.table(task, file=paste(selection, "\\task-", Sys.Date(), ".csv", sep=""), sep=",", row.names=FALSE, col.names=FALSE, quote=FALSE, append=FALSE)
  
  write.table(task, file=paste(selection, "\\task",  ".csv", sep=""), sep=",", row.names=FALSE, col.names=FALSE, quote=FALSE, append=FALSE)
  
  }
  
  dispose(win)
  
  
  
  
  })
  
  help.button &lt;- gbutton("Help", container=group3, handler = function(h,...) {
  
  confirmDialog("If the file is not being written, edit the write.table function", handler = function(h,...) {
  
  
  dispose(h$obj)
  })
  
  })
  
  
  })
  </code></pre>