Question

I'm using the pixmap library here. For instance, I have some grid.pnm file I want to save in interactive mode. It seems like there are only save options for more common extensions such as jpeg, png, etc.

> grid <- read.pnm("grid.pnm")
> segments(50,100,60,120, col = 'pink')
> save(grid) //Error 

What is the correct function here?

Thanks

Was it helpful?

Solution

I'm going to make the assumption that you've already looked at the help page for write.pnm and that is not what you want. That means that you have the incorrect notion that there is a .pnm graphics format. There is not. The pixmap class (actually several classes) is a data storage format where most of the data is in a slot named "index" which hold a matrix. It uses the base graphics function image to overlay pixellated data onto other plots or just onto a graphics device. There are no pixmap readers out ther that would be able to render a .pnm file.

 findMethods("plot")    #  prints out a long list of methods
   ......
 $`pixmap#ANY
   ......
      image(x = X, y = Y, z = t(x@index[nrow(x@index):1, , 
        drop = FALSE]), col = x@col, xlab = xlab, ylab = ylab, 
        axes = axes, asp = asp, ...)

So the image data is in that "index" slot and there are other modifier slots like "col"(color), "bbox", "cellres" that are used to set up the plotting dimensions and colorize it. So .pnm is just an R-thing. So I suppose you could think of R as the .pnm reader and end up storing as .pnm, but I sounds to me that you are wanting a recognized image format, and for that you need to Save as.. with the formats offered at your console session. Or you can use one of the other formats which you can list with capabilities().

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top