[R] Request for users of my R-Tcl/Tk examples, limmaGUI or affylmGUI

2006-02-02 Thread James Wettenhall
[PLEASE REPLY _OFF_ THE LIST, i.e. DON'T CC to [EMAIL PROTECTED]

Hi,

I don't see this sort of thing very often on the mailing lists, so list
moderators and others should feel free to tell me if it breaches list
etiquette and/or delete my post if necessary.  But I can't see what harm
it could do...

I am just wondering approximately how many people use / have used some of
the R stuff I've developed (and in how many countries).  In particular I'm
talking about the R-Tcl/Tk examples I've put at
http://bioinf.wehi.edu.au/~wettenhall/RTclTkExamples/ and/or my two BioC
packages limmaGUI and affylmGUI (now maintained by Keith Satterley),
and/or the IBC2004 and JSM2005 microarray analysis course websites.

If it's not too much trouble, could you please tell me [OFF THE LIST] if
you use / have used any of these things (otherwise don't reply) and what
country you are from, and if there are many other people where you work
who use them but would not reply on the R mailing list themself? e.g.

I use / have used your R-Tcl/Tk Examples.  I am from Canada.  Two other
people I work with have also used them, but they don't read the R mailing
lists so won't reply themselves.

If I get an absolutely massive response, I may have to set up some harsh
email filters and delete some of the incoming replies, but I think I can
handle the sort of response I am expecting.

Apologies if anyone feels that I am misusing the mailing list(s).

Best wishes to all,
James

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] Debugging R/Fortran in Windows

2005-09-08 Thread James Wettenhall
Hi,

I'm trying to debug an R interface to a Fortran subroutine from Windows. 
(Yes, I know I should try Unix/Linux as well, but a quick attempt
suggested that the (MinGW g77) Fortran compiler I have installed on my
Windows laptop works better on this Fortran code.)

I'm trying to follow the instructions in the Writing R Extensions Manual:

Start R under the debugger after setting a breakpoint for WinMain.
  gdb .../bin/Rgui.exe
  (gdb) break WinMain
  (gdb) run

But when I run gdb on Rgui.exe, I get the message:
no debugging symbols found
and then when I try break WinMain, I get:
No symbol table is loaded.  use the 'file' command.

I'm using R 2.1.1 on Windows 2000 and gdb 5.2.1 from MSys's MinGW.

I'm calling a Fortran function (several times) from R.  And I seem to have
the basic two-way data communication working - I appear to have
succesfully passed all required data types (integer, real, double
precision) to and from Fortran with sensible results both from within R
and from using WRITE(FILENUM,*) from within Fortran.  But unfortunately
there is still evidence of memory leakage.

Any suggestions would be greatly appreciated.

Regards,
James

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] Non-Linear Regression (Cobb-Douglas and C.E.S)

2004-04-18 Thread James Wettenhall
On Sun, 18 Apr 2004, Mohammad Ehsanul Karim wrote:
 concern (In this case there is no way to linearize it), the Cobb-Douglas 
 being just a 'Toy problem' to see how non-linear process works. And i'm 
 sorry that i cannot guess some approximate parameter values for that CES 
 using some typical Y,L,K data : that why it is a problem (doing a grid 
 search over infinite parameter space is indeed time consuming).

Mohammed,

OK, so you really do want to try nonlinear regression.  That's 
fine as long as you know that there are a lot more things that 
can go wrong than with linear regression.  Have you read the 
references at the end of the help for nls?  (I have to admit I 
haven't yet.)

Do you know under what conditions your cost function will be 
convex with respect to the parameters you are estimating?  The 
sum of convex functions is convex.  So if every one of your 
squared-error terms is convex then the sum will be.

Let's say you are minimizing this cost function: 
  Sum_i (Y_i - f(delta,beta,phi)_i)^2

where f()_i is your C.E.S. function evaluated at 
each data point (L_i,K_i).

Can you calculate the Hessian matrix (second derivative matrix) 
of the cost function with respect to the parameters, and see 
under what conditions it is positive definite?  (i.e. under 
what conditions is your cost function convex?)

A non-convex cost function is one possible reason why a 
nonlinear optimization routine may have trouble converging.  
There are some fiddles you can apply if you don't have convexity 
but they don't always work.  For example, in Newton descent, you 
use a Hessian matrix to calculate a descent step and in BFGS you 
use an approximate inverse Hessian to calculate a descent step.  
If the Hessian is not positive definite, you can cheat by making 
it positive-definite by using a modified cholesky factorization, 
e.g. Schnabel and Eskow.  This should guarantee a descent 
direction.

Sometimes you don't need a Hessian to be positive-definite in 
all directions, only within the subspace dictated by the 
constraints.  For example the negative(*) Cobb-Douglas utility 
function (for two commodities) is not convex over all R2 but it 
is convex in the subspace in which the budget constraint is 
satisfied at equality.  I'm not talking about regression here, 
just max utility subject to budget constraint.

(*) negative, because instead of maximizing utility and having 
to talk about concavity I want to talk about minimizing 
negative utility so I can talk about convexity.

Consider a second-order Taylor approximation about a potential 
minimizing solution x*.  x is the vector of parameters.  g is 
the cost function (because I already used 'f' above for the 
C.E.S. function).  x* is the optimal solution.  If there's 
any chance of standard nonlinear optimization working, we 
hope that g'(x*) is zero.

g(x) = g(x*) + g'(x*)(x-x*) + (1/2)(x-x*)T g''(x*) (x-x*)

(where T means transpose)

So with g'(x*) = 0, we have

g(x)-g(x*) = (1/2)(x-x*)T g''(x*)(x-x*)

So if we move in a direction x-x* away from the optimal point 
x*, we want this to always be positive (strictly convex, 
positive definte hessian), or at least never be negative 
(positive semi-definite hessian).  g''(x*) is the Hessian 
evaluated at the optimal solution.

There are many ways to test positive-definiteness.  If all the 
eigenvalues are positive the matrix is positive definte.  There 
are several ways to test positive definiteness over the subspace 
dictated by your constraints, e.g. a bordered hessian.

Good luck,
James

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] Non-Linear Regression (Cobb-Douglas and C.E.S)

2004-04-16 Thread James Wettenhall
Mohammed,

 For estimating Cobb-Douglas production Function [ Y = ALPHA * 
 (L^(BETA1)) * (K^(BETA2))  ], i want to use nls function 
 (without linearizing it). But how can i get initial values? 

This might be a dumb question, but why do you need nonlinear 
regression for that model?  It is linear after taking logs:

log Y = log ALPHA + BETA1 log L + BETA2 log K

 2. How can i estimate C.E.S Production Function [  Y = GAMA * 
 ((DELTA*K^(-BETA)) + ((1-DELTA)*L^(-BETA)))^(-PHI/BETA)  ] 

Your second model (C.E.S. Prod. Fcn) does indeed look nonlinear, 
and I'm sorry I can't think how to find a good point 
around which to linearize. Can you guess some approximate 
parameter values for some typical Y,L,K data?  

If it's too hard to estimate parameters 
for a model, maybe it's time to come up with a new model :)

Regards,
James

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] Use R function in C code

2004-04-15 Thread James Wettenhall
Hi,

On Fri Apr 2, xt_wang wrote:
 I want to use R function Matrix inverse in my c code, please 
 tell me how I can.
 If there is a sample which can tell me how it works. It will 
 be fantastic.

A good place to start learning how to interface R with C is the 
Writing R Extensions manual installed locally, or:
http://cran.r-project.org/doc/manuals/R-exts.pdf
http://rweb.stat.umn.edu/R/doc/manual/R-exts.html

See also the article In Search of C/C++  Fortran Routines in: 
http://cran.r-project.org/doc/Rnews/Rnews_2001-3.pdf

I guess you'd have to decide whether you want to compile R as a 
shared library or not.  I've never done this.

But do you really want to call R from C to get a matrix inverse?  
Can't you just use a CLAPACK routine?
http://www.netlib.org/clapack/

I'm not sure which CLAPACK subroutine is best for your purposes, 
but I have in the past used dgels (double-precision gaussian 
elimination and least-squares) and found it to be good.

I assume you have asked the question: 
Do I really need an inverse?

If Ax = b,
x = inv(A) * b 
is computationally about twice as expensive as Gaussian 
Elimination.

In R, to get help on solving linear systems, try:
?solve

 A - matrix(c(1,2,3,4),nrow=2)
 Ainv - solve(A)
 A %*% Ainv
 [,1] [,2]
[1,]10
[2,]01

Hope this helps,
James

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] Passing a pointer to .C() in Win32

2004-04-15 Thread James Wettenhall
I sent this to R-help recently, but I'm not sure if it was
received correctly.  It it is in:
https://www.stat.math.ethz.ch/pipermail/r-help/2004-April.txt.gz
but not yet in:
http://tolstoy.newcastle.edu.au/R/help/04/04/index.html
Apologies if I've sent it twice.

On Thu, 15 Apr 2004, James Wettenhall wrote:
Hi,

Is there any way to pass an integer from R to C and have
it cast as a pointer?

# Win32 Example:

library(tcltk)
tt - tktoplevel()
hWndString - tclvalue(tkwm.frame(tt))
# I'll avoid posting code to this function:
source(http://bioinf.wehi.edu.au/folders/james/R/hexStringToDecimalInteger.R;)
hWnd - hexStringToDecimalInteger(hWndString)
system32 - file.path(Sys.getenv(windir),system32)
user32 - file.path(system32,user32.dll)
dyn.load(user32)

# WARNING: THIS NEXT LINE WILL PASS AN INVALID WINDOW HANDLE TO
# USER32.DLL AND PROBABLY CRASH YOUR R SESSION
.C(SetForegroundWindow,hWnd)

# This above won't work, because .C() will pass a pointer to the
# integer hWnd to SetForegroundWindow (in user32.dll) whereas
# I want the integer hWnd to be cast as a pointer.

So for each DLL function I want to call with a pointer argument,
do I have to define my own C function e.g. my_SetForegroundWindow
(using the Windows API) which takes an integer argument instead
and then casts it as a pointer in order to call the real
SetForegroundWindow function?

Of course environments behave like pointers but they are
read-only.  You can't do this (below), right?
mode(hWnd) - environment

WHY WOULD I WANT TO DO ANYTHING LIKE THIS ABOVE?

I know that I can use tkfocus for Tk windows, but I have other
applications in mind.  In Win32, when I run RGui with MDI, the
bringToTop in tcltk's .onLoad brings the console to the top, but
doesn't focus it, i.e. after library(tcltk), I can't type into
the console until I click on it.  Now if I had RConsole-handle
from the GraphApp code for RGui, maybe I could try something
like SetForegroundWindow... For more info, go to
http://msdn.microsoft.com and search for BringWindowToTop,
search for SetForegroundWindow, and compare...

Maybe for this particular application, something like
show(RConsole) might be better, (see R-devel thread below)
http://www.mail-archive.com/[EMAIL PROTECTED]/msg01829.html

but I'm still wondering if casting to pointers can be done...

Another application is specifying a Tk window to be Always On
Top using user32.dll's SetWindowPos function (again, search
for it on http://msdn.microsoft.com).

Regards,
James

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] Passing a pointer to .C() in Win32

2004-04-14 Thread James Wettenhall
Hi,

Is there any way to pass an integer from R to C and have 
it cast as a pointer?  

# Win32 Example:

library(tcltk)
tt - tktoplevel()
hWndString - tclvalue(tkwm.frame(tt))
# I'll avoid posting code to this function:
source(http://bioinf.wehi.edu.au/folders/james/R/hexStringToDecimalInteger.R;)
hWnd - hexStringToDecimalInteger(hWndString)
system32 - file.path(Sys.getenv(windir),system32)
user32 - file.path(system32,user32.dll)
dyn.load(user32)

# WARNING: THIS NEXT LINE WILL PASS AN INVALID WINDOW HANDLE TO 
# USER32.DLL AND PROBABLY CRASH YOUR R SESSION
.C(SetForegroundWindow,hWnd)

# This above won't work, because .C() will pass a pointer to the 
# integer hWnd to SetForegroundWindow (in user32.dll) whereas 
# I want the integer hWnd to be cast as a pointer.

So for each DLL function I want to call with a pointer argument, 
do I have to define my own C function e.g. my_SetForegroundWindow 
(using the Windows API) which takes an integer argument instead 
and then casts it as a pointer in order to call the real 
SetForegroundWindow function?

Of course environments behave like pointers but they are 
read-only.  You can't do this (below), right?
mode(hWnd) - environment

WHY WOULD I WANT TO DO ANYTHING LIKE THIS ABOVE?

I know that I can use tkfocus for Tk windows, but I have other 
applications in mind.  In Win32, when I run RGui with MDI, the 
bringToTop in tcltk's .onLoad brings the console to the top, but 
doesn't focus it, i.e. after library(tcltk), I can't type into 
the console until I click on it.  Now if I had RConsole-handle 
from the GraphApp code for RGui, maybe I could try something 
like SetForegroundWindow... For more info, go to 
http://msdn.microsoft.com and search for BringWindowToTop, 
search for SetForegroundWindow, and compare...

Maybe for this particular application, something like 
show(RConsole) might be better, (see R-devel thread below)
http://www.mail-archive.com/[EMAIL PROTECTED]/msg01829.html

but I'm still wondering if casting to pointers can be done...

Another application is specifying a Tk window to be Always On 
Top using user32.dll's SetWindowPos function (again, search 
for it on http://msdn.microsoft.com).

Regards,
James

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


RE: [R] select text using only the keyboard

2003-10-24 Thread James Wettenhall
Simon,

 I have a different wish: I want to be able to mouseclick in
 the middle of a line to get the cursor there (as in SPlus).

 While I appreciate that to get my wish I should just write
 a little patch, I estimate it would take me about 2 years
 to reach the point where I was capable of it,

Depends on how much C programming you've done.  I could possibly 
write a patch in less than 2 years, but I have other things 
which are higher priority right now.  Here are some things you 
would need to look at:

Mouse-button event-handlers in GraphApp:
http://www.cs.usyd.edu.au/~graphapp/doc/manual/mouse.htm

Setting the cursor position/selection in a text window in 
GraphApp:
http://www.cs.usyd.edu.au/~loki/graphapp/manual/textedit.htm

Building R for Windows:
http://www.stats.ox.ac.uk/pub/Rtools/

Regards,
James

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] Installing from RPM on Red Hat 9

2003-09-19 Thread James Wettenhall
Ted,

If you are missing a shared library (libtk8.3.so) then you could 
just find the appropriate rpm on the RedHat9 CDs, perhaps 
tk-8.3.5-88.i386.rpm in /RedHat/RPMS on the second CD, and install 
it with sudo rpm -i.

BUT, there are some known bugs in the Tcl/Tk that comes with 
Redhat 9 (which don't exist in previous Redhat distributions) :

https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=89098
https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=101678
https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=100793
http://www.interlink.com.au/anthony/tech/rh9-tcltk/

What I did recently on Redhat 9 is install Tcl/Tk 8.4 from 
source (configure;make;make install; for Tcl, then for Tk) and 
then install R from source (configure;make;make install).  You 
can get Tcl/Tk source from www.tcl.tk and to build them you need 
the X11 developer's kit which can be installed from rpm off the 
Redhat9 CDs : Install XFree86-devel-4.3.0-2.i386.rpm which requires 
fontconfig-devel-2.1-9.i386.rpm and freetype-2.1.3-6.i386.rpm.

Installing R from source will put it (by default) in 
/usr/local/bin/R rather than /usr/bin/R

HTH,
James

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] Tktable White column when WIDTH13

2003-07-30 Thread James Wettenhall
Sorry to those not interested in R/TclTk for yet another email!

Thomas found possibly a better way to fix the white column on 
the right problem :
tkconfigure(table1,colstretchmode=unset)

Also, he asked how to justify text to the left in cells, noting 
that justify=left didn't work and that the help for justify 
only mentioned multi-line cells.

His solution was :
tkconfigure(table1,anchor=w)

Or for an individual tagged cell:
tkcmd(.Tk.ID(table1),tag,cell,ZeroOne,0,1)
tkcmd(.Tk.ID(table1),tag,configure,ZeroOne,anchor=e)

James

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] Tktable White column when WIDTH13

2003-07-30 Thread James Wettenhall
On Wed, 30 Jul 2003 [EMAIL PROTECTED] wrote:
SNIP
table1 - tkwidget(tt,table,variable=tclArray,
rows=as.character(dim(datifram)[1]+1),
cols=as.character(dim(datifram)[2]),titlerows=1,
titlecols=3,selectmode=extended,height=27,
width=13,bg=white,state=disabled,cursor=arrow,
drawmode=single,selectmode=single,invertselected=TRUE,
xscrollcommand=function(...)tkset(xscr,...),
yscrollcommand=function(...) tkset(yscr,...))
SNIP

 When I go to the right border with the scrollbar, I see a 
 wihte column without cells and without titlerow. I could 
 determine where the problem is.
 But I don't know why this problem is. When I set the WIDTH 
 in tkwidget() lower than 13, this white column doesn't appear. 
 If the WIDTH is equal to 13 or higher, than the white column 
 appears. Can you help me how to eliminate
 this white column when I want to have more than 12 columns in 
 the window?


Thomas,

I think the Tktable geometry manager is having trouble because
you have asked it to display 13 columns on the screen and the
default column width is 10 characters in the default font.
Can you fit 130 characters across your screen easily?

Perhaps you could specify colwidth=5 or something smaller than
10 when you create the table, then later on, you could widen
some columns with :

tkcmd(.Tk.ID(table1),width,0,10)
tkcmd(.Tk.ID(table1),width,1,10)
...
(to widen the first 2 columns to 10 characters)

Or don't specify the width option (number of columns) in 
tkwidget(tt,table,width = ...
Just leave it to Tktable.

Regards,
James

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] Tktable active cell

2003-07-28 Thread James Wettenhall
Thomas Sudler [EMAIL PROTECTED] wrote:
 I want to start an action when i click into a cell. Example: 
When I click
 into a cell, a message box should open with the information of 
the
 location of the cell where I clicked in. SNIP So I only
 need to know how to get the possition of the active cell.

Thomas,

Getting the active cell is easy, just use :
 
row - tclvalue(tkindex(table1,active,row))
col - tclvalue(tkindex(table1,active,col))  

But if you try to catch the left-button-click event and then 
display the cell coordinates in a message box, the problem is 
that your event handler will be run BEFORE the default event 
handler which updates the active cell, so you will get the 
PREVIOUS active cell, (and the first time you will get an 
error because there is no active cell).

The Tcl help for bind :
http://aspn.activestate.com/ASPN/docs/ActiveTcl/ActiveTcl8.4.1.0-html/tcl/TkCmd/bind.htm
suggests that you may be able to use a + in front of your 
event handler name so that it is appended to any existing 
binding, but this feature may not be implemented in R Tcl/Tk 
yet, e.g. this didn't seem to work:

tkbind(table1,Button 1,paste(+,.Tcl.callback(onLeftClick),sep=))


Regards,
James

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] Tktable cell colors

2003-07-28 Thread James Wettenhall
Thomas Sudler [EMAIL PROTECTED] wrote:
 color of all the cells, that's no problem. But is it also 
possible to define
 another color for different cells? (example: Cell at position 
[1,1]:red,

Thomas,

Try this:

require(tcltk)
tclRequire(Tktable)
tt - tktoplevel()
table1 - tkwidget(tt,table)
tkpack(table1)
tkcmd(.Tk.ID(table1),tag,celltag,ZeroZero,0,0)
tkcmd(.Tk.ID(table1),tag,celltag,ZeroOne,0,1)
tkcmd(.Tk.ID(table1),tag,configure,ZeroZero,bg=red)
tkcmd(.Tk.ID(table1),tag,configure,ZeroOne,bg=blue)

Regards,
James

 Thank you very much for your answer. It works great.
 Thomas.

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] Tktable change cell values

2003-07-28 Thread James Wettenhall
Thomas Sudler [EMAIL PROTECTED] wrote:
 And my last question: How can I change the value of a cell? (I 
mean not by
 clicking into the cell... I mean how I can change the value 
with a
 command).

Thomas,

Currently there is no official interface between R arrays and 
Tcl arrays, so you have to write your own.

I've sketched some ideas on :
http://bioinf.wehi.edu.au/~wettenhall/RTclTkExamples/tktable.html

Here's a summary.

Regards,
James

The tclArrayVar is a modified version of Peter Dalgaard's 
tclVar function.

require(tcltk)
tclRequire(Tktable)

tclArrayVar - function()
{
n - evalq(TclVarCount - TclVarCount + 1, .TkRoot$env)
name - paste(::RTcl, n,sep = )
l - list(env = new.env())
assign(name, NULL, envir = l$env)
reg.finalizer(l$env, function(env) tkcmd(unset, ls(env)))
class(l) - tclArrayVar
.Tcl(paste(set ,name,(0,0) \\,sep=))
l
}

assign([.tclArrayVar,
function(object, i, j) {
  tclArrayName - ls(object$env)
  tclvalue(paste(tclArrayName,(,i,,,j,),sep=))
})

assign([-.tclArrayVar,
function(object, i,j,value) {
  tclArrayName - ls(object$env)
  .Tcl(paste(set ,tclArrayName,(,i,,,j,) ,value,sep=))  
  return(object)
})

tt - tktoplevel()
tclArray - tclArrayVar()
tclArrayName - ls(tclArray$env)
table1 - tkwidget(tt,table,variable=tclArrayName)
tkpack(table1)

# Set/Modify the values of some cells.
tclArray[0,0] - Zero
tclArray[0,1] - One
tclArray[1,0] - Two
tclArray[1,1] - Three

# Now get the value of a cell.
tclArray[0,1]

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] Calling R from C

2003-07-22 Thread James Wettenhall

Duncan Temple Lang's article In Search of C/C++  
Fortran Routines in R News Vol 1/3, September 2001 is 
definitely worth reading (even though it's mainly about calling 
C from R):
http://cran.r-project.org/doc/Rnews/Rnews_2001-3.pdf

and you should have a look at Writing R Extensions :
http://cran.r-project.org/doc/manuals/R-exts.pdf

James

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


[R] R_GlobalEnv

2003-05-27 Thread James Wettenhall
Hi,

I'm trying to access the current R global environment from 
within C, using R_GlobalEnv.

In the example below, Rgui (R 1.7.0. Win2K) crashes when I try 
to run assignValueToFooInR_GlobalEnv, but not when I run 
assignValueToFooInRhoEnv with Rho=.GlobalEnv.  Can anyone tell me why?

[ My motivation is that I want use defineVar to initialise a 
workingEnvironment (corresponding to Value below), so that event-handler 
functions for a specific C library (which must have a specific 
prototype) can call R functions by looking up workingEnvironment with 
findVar. Earlier, I tried a static global SEXP variable in C to 
keep track of the environment, but that's not reliable because 
of garbage collection. Maybe SEXPREC would work better? ]

Thanks in advance,
James


* testR_GlobalEnv.c *
#include R.h
#include Rinternals.h
#include R_ext/Rdynload.h
#include R_ext/Memory.h
#include R_ext/Applic.h

static SEXP assignValueToFooInRhoEnv(SEXP Value,SEXP Rho)
{
defineVar(install(Foo),Value,Rho);
return Value;
}

static SEXP assignValueToFooInR_GlobalEnv(SEXP Value)
{
defineVar(install(Foo),Value,R_GlobalEnv);
return Value;
}

static const
R_CallMethodDef CallEntries[] = {
{assignValueToFooInRhoEnv, 
(DL_FUNC)assignValueToFooInRhoEnv,2},
{assignValueToFooInR_GlobalEnv, 
(DL_FUNC)assignValueToFooInR_GlobalEnv,1},
{NULL,NULL,0}
};

void R_init_testR_GlobalEnv(DllInfo *info)
{
  R_registerRoutines(info,NULL,CallEntries,NULL,NULL);
}


* In R *
 dyn.load(testR_GlobalEnv)
 .Call(assignValueToFooInRhoEnv, 5, .GlobalEnv)
[1] 5
 Foo
[1] 5
 .Call(assignValueToFooInR_GlobalEnv, 5)

Then Rgui crashes!

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


[R] R TclTk iwidgets::comboboc

2003-03-26 Thread James Wettenhall
Hi,

I am trying to create a drop-down combobox in R TclTk.  

The following works fine for a ListBox but fails for a combobox:

# THIS WORKS FINE - CREATES AN EMPTY LISTBOX ##
tt-tktoplevel()
win - .Tk.subwin(tt)
.Tcl(paste(listbox,.Tk.ID(win),.Tcl.args()))
tkpack(win)

## THIS FAILS - ATTEMPTS TO CREATE A COMBOBOX ##
tt-tktoplevel()
win - .Tk.subwin(tt)
.Tcl(paste(iwidgets::combobox,.Tk.ID(win),.Tcl.args()))
Error in structure(.External(dotTcl, ..., PACKAGE = tcltk), 
class = tclObj) : 
[tcl] .

I am using R 1.6.2 (with tcltk package 1.6.2) and ActiveTcl 
8.3.5.0 in Windows 2000.  Below I've included some of the 
relevant ActiveTcl help.  I'm not sure why it has funny characters.


#
# Nonâ.editable Dropdown Combobox
#
iwidgets::combobox .cb1 â.labeltext Month: \ â.selectioncommand 
{puts «selected: [.cb1 getcurselection]} \ â.editable false 
â.listheight 185 â.popupcursor hand1 .cb1 insert list end Jan 
Feb Mar Apr May June Jul Aug Sept Oct Nov Dec

BTW, Thanks very much to all organizers and presenters at the 
DSC 2003 - a huge sucess!

Regards,
James

--
James Wettenhall  Tel: (+61 3) 9345 2629
Division of Genetics and Bioinformatics   Fax: (+61 3) 9347 0852
The Walter  Eliza Hall Institute E-mail: [EMAIL PROTECTED]
 of Medical Research, Mobile: (+61 / 0 ) 438 527 921
1G Royal Parade,
Parkville, Vic 3050, Australia
http://www.wehi.edu.au
--

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] R TclTk iwidgets::combobox

2003-03-26 Thread James Wettenhall
Thanks Peter,

I've started a new R session (in Windows) and managed to get 
both ways working now : 

### THIS WORKS !!! ###
library(tcltk)
tclRequire(IWidgets)
tt-tktoplevel()
combo - tkwidget(tt,iwidgets::combobox)
tkpack(combo)

### AND THIS WORKS TOO !!! ###
tt-tktoplevel()
win - .Tk.subwin(tt)
.Tcl(paste(iwidgets::combobox,.Tk.ID(win),.Tcl.args()))
tkpack(win)

But they both fail in my old R session - maybe I've tclRequired 
another package or loaded another package which is interfering 
or maybe a Tcl object hasn't been cleaned from memory properly.

Thanks very much for your help!
Regards,
James



On 27 Mar 2003, Peter Dalgaard BSA wrote:

 James Wettenhall [EMAIL PROTECTED] writes:
 
  Hi,
  
  I am trying to create a drop-down combobox in R TclTk.  
  
  The following works fine for a ListBox but fails for a combobox:
  
  # THIS WORKS FINE - CREATES AN EMPTY LISTBOX ##
  tt-tktoplevel()
  win - .Tk.subwin(tt)
  .Tcl(paste(listbox,.Tk.ID(win),.Tcl.args()))
  tkpack(win)
  
  ## THIS FAILS - ATTEMPTS TO CREATE A COMBOBOX ##
  tt-tktoplevel()
  win - .Tk.subwin(tt)
  .Tcl(paste(iwidgets::combobox,.Tk.ID(win),.Tcl.args()))
  Error in structure(.External(dotTcl, ..., PACKAGE = tcltk), 
  class = tclObj) : 
  [tcl] .
 
 Hmm, can't see why that shouldn't work. On Linux, this seems to work fine:
 
 tt-tktoplevel()
 combo - tkwidget(tt,iwidgets::combobox)
 tkpack(combo)
 
 and your code seems to work as well...
 
 You remembered to tclRequire(Iwidgets), I assume?
 
 

-- 
--
James Wettenhall  Tel: (+61 3) 9345 2629
Division of Genetics and Bioinformatics   Fax: (+61 3) 9347 0852
The Walter  Eliza Hall Institute E-mail: [EMAIL PROTECTED]
 of Medical Research, Mobile: (+61 / 0 ) 438 527 921
1G Royal Parade,
Parkville, Vic 3050, Australia
http://www.wehi.edu.au
--

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help