[R] tclarray with embedded spaces in data

Peter Dalgaard p.dalgaard at biostat.ku.dk
Wed Jan 21 02:04:38 CET 2009


Ruth M. Ripley wrote:
> I would like to use a tclArray:
> 
> mytkarray <- tclArray()
> 
> as the variable for a table:
> 
> table1 <- tkwidget(f1, 'table', variable= mytkarray)
> 
> but if I include character strings with embedded spaces, I get braces
> appearing in the table.
> 
> I can remove them using a non-R tclarray, (the difference between the
> first example of
> 
> http://www.sciviews.org/_rgui/tcltk/Tktable.html
> 
> and
> 
> http://bioinf.wehi.edu.au/~wettenhall/RTclTkExamples/tktable.html
> 
> - the result of the second of which includes the braces (although not in
> the image provided!) and that of the first does not - but this seems
> undesirably complicated. Am I missing something simple?
> 
> Any insights would be gratefully received,

(Didn't anyone tell you to cook up a selfcontained example?)

This is a right-honourable pain with Tcl, and it took me quite some time 
to reconstruct what I did several years ago on this matter. The short 
answer is that you need to assign things like

as.tclObj("foo bar   baz", drop=TRUE)

into your array. The longer story involves the ambiguity in Tcl between 
lists of words separated by whitespace and strings with spaces inside. I 
suspect that the sciviews approach doesn't actually cover all cases, 
paste()'ing raw tcl commands together usually leaves you burning in 
Quoting Hell.


> 
> Regards,
> 
> Ruth
> --
> Ruth M. Ripley,                         Email:ruth at stats.ox.ac.uk
> Dept. of Statistics,                    http://www.stats.ox.ac.uk/~ruth/
> University of Oxford,                   Tel:   01865 282851
> 1 South Parks Road, Oxford OX1 3TG, UK  Fax:   01865 272595
> 
> ______________________________________________
> 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.


-- 
    O__  ---- Peter Dalgaard             Øster Farimagsgade 5, Entr.B
   c/ /'_ --- Dept. of Biostatistics     PO Box 2099, 1014 Cph. K
  (*) \(*) -- University of Copenhagen   Denmark      Ph:  (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)              FAX: (+45) 35327907




More information about the R-help mailing list