Note that there are some explanatory texts on larger screens.

plurals
  1. POManipulating subsections of an array
    primarykey
    data
    text
    <p>I am using R to plot trying to conditionally change parts of an array based on the columns of the array.</p> <p>I have worked out the following steps:</p> <pre><code>x&lt;-array(1,dim=c(4,4,3)) r&lt;-x[,,1] g&lt;-x[,,2] b&lt;-x[,,3] r1&lt;-apply(r[,2:3],1:2,function(f){return(0)}) g1&lt;-apply(g[,2:3],1:2,function(f){return(0)}) b1&lt;-apply(b[,2:3],1:2,function(f){return(0)}) r3&lt;-cbind(r[,1],r1,r[,4]) g3&lt;-cbind(g[,1],g1,g[,4]) b3&lt;-cbind(b[,1],b1,b[,4]) # Pass to pixmapRGB </code></pre> <p>This works, but as I am new to R, I was wondering if there was a more efficient way to manipulate parts of an array.</p> <p>For example, does apply know which element it is working on?</p> <p>The bigger picture is that I want to graph a time-series scatter plot over many pages.</p> <p>I would like to have a thumbnail in the corner of the page that is a graph of the whole series. I would like to color a portion of that thumbnail a different color to indicate what range the current page is examining.</p> <p>There is alot of data, so it is not feasible to redraw a new plot for the thumbnail on every page.</p> <p>What I have done is to first write the thumbnail plot out to a tiff file. Then I read the tiff file back in, used getChannels from pixmap to break the picture into arrays, and used the above code to change some of the pixels based on column. Finally I then print the image to a viewport using pixmapRGB/pixmapGrob/grid.draw</p> <p>It seems like alot of steps. I would be grateful for any pointers that would help me make this more efficient.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload