Immanuel Seeger
2010-Aug-05 09:55 UTC
[R] Error in as.environment(pos): using 'as.environment(NULL)' is defunct
Hello, I?m using R 2.11.1 with Tinn-R 1.17.2.4. I hope the given informations are enough (it?s my first entry here) The as.environment(pos) error appears in using the following code which should open a function in an other R-file. Here some extractions of the code: .... HZ<-tclVar(seq(length=a,from=1,by=0)) #(a is defined by a tkentry-element) VZ<-tclVar(seq(length=a,from=1,by=0)) Aktivit?t<-tclVar(seq(length=a,from=1,by=0)) VKG<-tclVar(3) Zugeh?rigkeit is a matrix. #The values can be changed by a tkentry-element. handler.Berechnung<-function() { tkconfigure(Ergebnisfenster, textvariable=tclVar(test2(as.numeric(tclObj(VKG)),as.numeric(tclObj(HZ)) ,as.numeric(tclObj(VZ)),as.numeric(tclObj(Aktivit?t)),as.numeric(tclObj( tclArray1))))) } test2 <- local({source("C:/Berechnung_Funktion.R", local = TRUE) environment(Berechnung) <- .GlobalEnv Berechnung }) and: Button<-tkframe(InputOutputfenster) tkpack(Button, side='top') tkpack(tkbutton(Button, text='compute optimal solution',command=handler.Berechnung)) and the function in the other R-file: Berechnung<-function(a,b,c,d,e) { } Thanks!
Immanuel Seeger
2010-Aug-08 08:58 UTC
[R] Error in as.environment(pos): using 'as.environment(NULL)' isdefunct
Hello, unfortunately I haven't gotten an answer up to now. You can see my question/problem below in the first mail. Is the given extract too unspecific? I haven't solved the problem but I think that it's in the handler.Berechnung function. Maybe I'm using wrong data-types (there are vectors defined by tclVar and 'Zugeh?rigkeit' as a matrix defined by tclArray). I'm new to R with TK and don't know if tclvar(as.numeric(tclObj(...))) is the right code to set vectors and matrices as textvariable.(see below in handler.Berechnung) Thanks! -----Urspr?ngliche Nachricht----- Von: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] Im Auftrag von Immanuel Seeger Gesendet: Donnerstag, 5. August 2010 11:56 An: r-help at r-project.org Betreff: [R] Error in as.environment(pos): using 'as.environment(NULL)' isdefunct Hello, I?m using R 2.11.1 with Tinn-R 1.17.2.4. I hope the given informations are enough (it?s my first entry here) The as.environment(pos) error appears in using the following code which should open a function in an other R-file. Here some extractions of the code: .... HZ<-tclVar(seq(length=a,from=1,by=0)) #(a is defined by a tkentry-element) VZ<-tclVar(seq(length=a,from=1,by=0)) Aktivit?t<-tclVar(seq(length=a,from=1,by=0)) VKG<-tclVar(3) Zugeh?rigkeit is a matrix. #The values can be changed by a tkentry-element. handler.Berechnung<-function() { tkconfigure(Ergebnisfenster, textvariable=tclVar(test2(as.numeric(tclObj(VKG)),as.numeric(tclObj(HZ)) ,as.numeric(tclObj(VZ)),as.numeric(tclObj(Aktivit?t)),as.numeric(tclObj( tclArray1))))) } test2 <- local({source("C:/Berechnung_Funktion.R", local = TRUE) environment(Berechnung) <- .GlobalEnv Berechnung }) and: Button<-tkframe(InputOutputfenster) tkpack(Button, side='top') tkpack(tkbutton(Button, text='compute optimal solution',command=handler.Berechnung)) and the function in the other R-file: Berechnung<-function(a,b,c,d,e) { } Thanks! ______________________________________________ R-help at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.