How to control the device output generated by visCompReorder?

Notes:
  • All results are based on supraHex (version 1.13.3).
  • R scripts (i.e. R expressions) plus necessary comments are highlighted in light-cyan background, and the rest are outputs in the screen.
  • Images displayed below may be distorted, but should be normal in your screen.
  • Functions contained in supraHex 1.13.3 are hyperlinked in-place and also listed on the right side.
  • Key texts are underlined, in bold and in pumpkin-orange color.
  •       
    # The output generated by visCompReorder is only shown in the screen. The reason for that is to make sure the supra-hexagon is seamlessly formed and visually friendly. # Internally, the function visVp opens a new page each time. # In order to save the output as a file, below is a universal solution of how to save an image shown in the screen into a file (eg a png file). ## First, install and load the package 'evaluate' # install.packages("evaluate",repos="http://cran.r-project.org",type="source") library(evaluate) ## Then, produce an image in the screen data <- matrix( rnorm(100*10,mean=0,sd=1), nrow=100, ncol=10) colnames(data) <- paste('S', seq(1:10), sep="") sMap <- sPipeline(data=data)
    Start at 2017-03-27 18:59:37 First, define topology of a map grid (2017-03-27 18:59:37)... Second, initialise the codebook matrix (61 X 10) using 'linear' initialisation, given a topology and input data (2017-03-27 18:59:37)... Third, get training at the rough stage (2017-03-27 18:59:37)... 1 out of 7 (2017-03-27 18:59:37) updated (2017-03-27 18:59:37) 2 out of 7 (2017-03-27 18:59:37) updated (2017-03-27 18:59:37) 3 out of 7 (2017-03-27 18:59:37) updated (2017-03-27 18:59:37) 4 out of 7 (2017-03-27 18:59:37) updated (2017-03-27 18:59:37) 5 out of 7 (2017-03-27 18:59:37) updated (2017-03-27 18:59:37) 6 out of 7 (2017-03-27 18:59:37) updated (2017-03-27 18:59:37) 7 out of 7 (2017-03-27 18:59:37) updated (2017-03-27 18:59:37) Fourth, get training at the finetune stage (2017-03-27 18:59:37)... 1 out of 25 (2017-03-27 18:59:37) updated (2017-03-27 18:59:37) 2 out of 25 (2017-03-27 18:59:37) updated (2017-03-27 18:59:37) 3 out of 25 (2017-03-27 18:59:37) updated (2017-03-27 18:59:37) 4 out of 25 (2017-03-27 18:59:37) updated (2017-03-27 18:59:37) 5 out of 25 (2017-03-27 18:59:37) updated (2017-03-27 18:59:37) 6 out of 25 (2017-03-27 18:59:37) updated (2017-03-27 18:59:37) 7 out of 25 (2017-03-27 18:59:37) updated (2017-03-27 18:59:37) 8 out of 25 (2017-03-27 18:59:37) updated (2017-03-27 18:59:37) 9 out of 25 (2017-03-27 18:59:37) updated (2017-03-27 18:59:37) 10 out of 25 (2017-03-27 18:59:37) updated (2017-03-27 18:59:37) 11 out of 25 (2017-03-27 18:59:37) updated (2017-03-27 18:59:37) 12 out of 25 (2017-03-27 18:59:37) updated (2017-03-27 18:59:37) 13 out of 25 (2017-03-27 18:59:37) updated (2017-03-27 18:59:37) 14 out of 25 (2017-03-27 18:59:37) updated (2017-03-27 18:59:37) 15 out of 25 (2017-03-27 18:59:37) updated (2017-03-27 18:59:37) 16 out of 25 (2017-03-27 18:59:37) updated (2017-03-27 18:59:37) 17 out of 25 (2017-03-27 18:59:37) updated (2017-03-27 18:59:37) 18 out of 25 (2017-03-27 18:59:37) updated (2017-03-27 18:59:37) 19 out of 25 (2017-03-27 18:59:37) updated (2017-03-27 18:59:37) 20 out of 25 (2017-03-27 18:59:37) updated (2017-03-27 18:59:37) 21 out of 25 (2017-03-27 18:59:37) updated (2017-03-27 18:59:37) 22 out of 25 (2017-03-27 18:59:37) updated (2017-03-27 18:59:37) 23 out of 25 (2017-03-27 18:59:37) updated (2017-03-27 18:59:37) 24 out of 25 (2017-03-27 18:59:37) updated (2017-03-27 18:59:37) 25 out of 25 (2017-03-27 18:59:37) updated (2017-03-27 18:59:37) Next, identify the best-matching hexagon/rectangle for the input data (2017-03-27 18:59:37)... Finally, append the response data (hits and mqe) into the sMap object (2017-03-27 18:59:37)... Below are the summaries of the training results: dimension of input data: 100x10 xy-dimension of map grid: xdim=9, ydim=9, r=5 grid lattice: hexa grid shape: suprahex dimension of grid coord: 61x2 initialisation method: linear dimension of codebook matrix: 61x10 mean quantization error: 4.74459667018025 Below are the details of trainology: training algorithm: batch alpha type: invert training neighborhood kernel: gaussian trainlength (x input data length): 7 at rough stage; 25 at finetune stage radius (at rough stage): from 3 to 1 radius (at finetune stage): from 1 to 1 End at 2017-03-27 18:59:37 Runtime in total is: 0 secs
    sReorder <- sCompReorder(sMap=sMap)
    Start at 2017-03-27 18:59:37 First, define topology of a map grid (2017-03-27 18:59:37)... Second, initialise the codebook matrix (30 X 61) using 'linear' initialisation, given a topology and input data (2017-03-27 18:59:37)... Third, get training at the rough stage (2017-03-27 18:59:37)... 1 out of 300 (2017-03-27 18:59:37) 30 out of 300 (2017-03-27 18:59:37) 60 out of 300 (2017-03-27 18:59:37) 90 out of 300 (2017-03-27 18:59:37) 120 out of 300 (2017-03-27 18:59:37) 150 out of 300 (2017-03-27 18:59:37) 180 out of 300 (2017-03-27 18:59:37) 210 out of 300 (2017-03-27 18:59:37) 240 out of 300 (2017-03-27 18:59:37) 270 out of 300 (2017-03-27 18:59:37) 300 out of 300 (2017-03-27 18:59:37) Fourth, get training at the finetune stage (2017-03-27 18:59:37)... 1 out of 1200 (2017-03-27 18:59:37) 120 out of 1200 (2017-03-27 18:59:37) 240 out of 1200 (2017-03-27 18:59:37) 360 out of 1200 (2017-03-27 18:59:37) 480 out of 1200 (2017-03-27 18:59:37) 600 out of 1200 (2017-03-27 18:59:37) 720 out of 1200 (2017-03-27 18:59:37) 840 out of 1200 (2017-03-27 18:59:37) 960 out of 1200 (2017-03-27 18:59:37) 1080 out of 1200 (2017-03-27 18:59:37) 1200 out of 1200 (2017-03-27 18:59:37) Next, identify the best-matching hexagon/rectangle for the input data (2017-03-27 18:59:37)... Finally, append the response data (hits and mqe) into the sMap object (2017-03-27 18:59:37)... Below are the summaries of the training results: dimension of input data: 10x61 xy-dimension of map grid: xdim=6, ydim=5, r=3 grid lattice: rect grid shape: sheet dimension of grid coord: 30x2 initialisation method: linear dimension of codebook matrix: 30x61 mean quantization error: 4.99079289882425 Below are the details of trainology: training algorithm: sequential alpha type: invert training neighborhood kernel: gaussian trainlength (x input data length): 30 at rough stage; 120 at finetune stage radius (at rough stage): from 1 to 1 radius (at finetune stage): from 1 to 1 End at 2017-03-27 18:59:37 Runtime in total is: 0 secs
    visCompReorder(sMap=sMap, sReorder=sReorder) ## Third, treat the last R expression as an input to the function evaluate::evaluate r_exp <- 'visCompReorder(sMap=sMap, sReorder=sReorder)'
    ## Last, save it into the file called 'test.png' (with width=1200 and resolution=72) x <- evaluate::evaluate(r_exp) wh <- dev.size(units="px")
    wth <- 1200 hgt <- wth*wh[2]/wh[1] res <- min(c(wth,hgt))*72/480 png("test.png", width=wth, height=hgt, res=res) on.exit(dev.off()) print(x)
    [[1]] $src [1] "visCompReorder(sMap=sMap, sReorder=sReorder)" attr(,"class") [1] "source"
    graphics.off()

    Source faq

    FAQ3.r

    Functions used in this FAQ