my objective is to show data in screen inside a tktable...
for that, the data must be in a TCL variable and not only in a R variable
like that:

library( tcltk )
mtcars_in_TCL <- tclArray()
for( i in 1:5 ) for( j in 1:5 ) mtcars_in_TCL[[ i,j ]] <-
as.matrix(mtcars)[ i,j ]

i thank by  attention
cleber

Em 08/12/2015 22:51, Bert Gunter escreveu:
Define: "transfer"

(  save/load should be efficient and fast within R, but you appear to
have something else in mind. What?)

Apologies if it's obvious and I just don't get it.

Cheers,

Bert


Bert Gunter

"Data is not information. Information is not knowledge. And knowledge
is certainly not wisdom."
    -- Clifford Stoll


On Tue, Dec 8, 2015 at 4:37 PM, Cleber N.Borges <kle...@yahoo.com.br> wrote:
hello all,
I intend transfer a big data.frame, more than 1e4 rows, more than 100
columns...
I found solutions (in internet and help pages) for small data.frame like the
showed bellow.
Big data.frames is very expensive in computation time in my approach
I would like to optimize this transfer anyway ...
I saw a function named "as.tclObj" that seems to me a promising form but
hard to code...
Somebody know a way more clever to do it?

thanks for tips
cleber

##########################################
library( tcltk )
nrow <- 10 ; ncol <- 100
# simulated data: data is originally a data frame
DF <- as.data.frame(matrix(round(runif(nrow*ncol),3),nr=nrow,nc=ncol))
######
# DF_tcl <- as.tclObj( as.matrix( DF ) )

tableDataTclArray <- tclArray()
for( i in 1:nrow( DF ) )
     tableDataTclArray[[ i, 0 ]] <- .Tcl( noquote( paste('format "',
rownames( DF )[ i ] , '"') ) )

for( i in 1:ncol( DF ) )
     tableDataTclArray[[ 0, i ]] <- .Tcl( noquote( paste('format "',
colnames( DF )[ i ] , '"') ) )


for( i in 1:nrow( DF ) )
     for( j in 1:ncol( DF ) )
         tableDataTclArray[[ i, j ]] <- DF[i,j]
######





##############################################
##############################################
##############################################
# my full code:
###############
library( tcltk ); tclRequire("Tktable")
wDataOrg <- tktoplevel()
tcl('wm', 'geometry',  wDataOrg, "1024x600+175+80" )
fmTableData <- ttklabelframe( wDataOrg, text='  Data  ', padding=c( 8, 5, 8,
15 ) )
height <- -1; width <- -1
nrowDefault <- 1e4+1; ncolDefault <- 100+1
tableDataTclArray <- tclArray()
tableData <- tkwidget( fmTableData, "table", rows=nrowDefault,
cols=ncolDefault,
                      height=height+1,width=width+1,
                      xscrollcommand=function(...) tkset( scrX, ... ),
                      yscrollcommand=function(...) tkset( scrY, ... ),
                      rowstretchmode='unset', colstretchmode='unset',
multiline=0, cache=1,
                      background="white", selectmode="extended",
selecttitle=0,
                      font='{Arial} 10', ipadx=5, ipady=5, anchor='e',
                      borderwidth=c( 0, 1, 0, 1 ), drawmode='slow',
                      variable=tableDataTclArray )
tcl( tableData, "tag", "celltag", "ZeroZero", "0,0" )
tcl( tableData, "tag", "rowtag",  "rowtitle", "0" )
tcl( tableData, "tag", "coltag",  "coltitle", "0" )
tcl( tableData, "tag", "configure", "ZeroZero", bg='SystemButtonFace',
relief="raised", state='disabled' )
tcl( tableData, "tag", "configure", "rowtitle", bg='lightgreen',
relief='raised', borderwidth=c( 0, 1, 0, 1 ), anchor='center' )
tcl( tableData, "tag", "configure", "coltitle", bg='lightgreen',
relief='raised', borderwidth=c( 0, 1, 0, 1 ), anchor='w' )
tcl( tableData, "tag", "configure", "active", fg='yellow', bg='red' )
tcl( tableData, "width", "0", "20" )
scrX <- tkscrollbar( fmTableData, orient="horizontal", command=function(...)
tkxview( tableData, ... ) )
scrY <- tkscrollbar( fmTableData, orient="vertical", command=function(...)
tkyview( tableData, ... ) )
scrYwidth <- as.integer( tkcget( scrY, width = NULL ) )
tcl( "pack", scrY, side = "right",  fill = "y", expand = FALSE, pady = c(0,
scrYwidth + 2) )
tcl( "pack", scrX, side = "bottom", fill = "x", expand = FALSE )
tcl( "pack", tableData, anchor='n', side="right", expand=TRUE, fill="both"
)
tcl( "pack", fmTableData, fill="both", expand = TRUE, padx=10, pady=10 )
##########################################  expensive time computation
[[elided Yahoo spam]]
DF <- as.data.frame( matrix( round(runif(1e4 * 100),3), nr=1e4, nc=100 ) )
#### simulated data
for( i in 1:nrow( DF ) ){
     tableDataTclArray[[ i, 0 ]] <- .Tcl( noquote( paste('format "',
rownames( DF )[ i ] , '"') ) )
     }
for( i in 1:ncol( DF ) ){
     tableDataTclArray[[ 0, i ]] <- .Tcl( noquote( paste('format "',
colnames( DF )[ i ] , '"') ) )
     }
for( i in 1:nrow( DF ) ) {
     for( j in 1:ncol( DF ) ){
         tableDataTclArray[[ i, j ]] <- DF[i,j]
     }
}
#





---
Este email foi escaneado pelo Avast antivĂ­rus.
https://www.avast.com/antivirus

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.

Reply via email to