Search code examples
rgwidgets

how can I retrieve changes to data frame edits from gdf


After making changes to a data frame using gdf, how do I retrieve the dataframe I have created?

Sample code:

require("gWidgets2RGtk2")
## Sample Data frame
x<-data.frame(a=c(1,2,3),b=c(4,5,6))
## Create Widget
w<-gwindow("gdf")
a<-gdf(x,cont=w)
## Makes some changes using widget
svalue(a)
> NULL

Solution

  • Managed to figure out the solution, although it doesn't seem very logical!

    a  #Doesn't work
    # Object of class GDf 
    a[1:nrow(a),1:ncol(a)]  # Works
    #    a  b
    # 1  1  4
    # 2  2  5
    # 3  3  6
    #   NA NA
    str(a[1:nrow(a),1:ncol(a)]) #Shows that this is a data frame
    # 'data.frame': 4 obs. of  2 variables:
    #  $ a: num  1 2 3 NA
    #  $ b: num  4 5 6 NA