read.pnm() - error trying to read pgm image

﹥>﹥吖頭↗ 提交于 2019-12-10 10:35:35

问题


I'm trying to read a pgm file in R. I set my wd to where the image is and then simply try to read it:

   setwd("~/3 Diplomado/5 Multivariado/lfwcrop_grey/faces")

   library(pixmap)

    x <- read.pnm(system.file("Aaron_Guiel_0001.pgm", package="pixmap")[1])

But I get the following error:

Error in if (ch == "#") { : argument is of length zero In addition: Warning message: In file(file, open = "rb") : file("") only supports open = "w+" and open = "w+b": using the former

Not sure what it is. I think it simply doesnt find the image. What am I doing wrong? any hints? Thank you in advanced!

J.


回答1:


Simply try this one:

x=read.pnm(file = "Aaron_Guiel_0001.pgm")

The system.file() is used to find the full path of the files included in packages. It is used in the package example, but you don't need to use it while reading your own file.



来源:https://stackoverflow.com/questions/12826051/read-pnm-error-trying-to-read-pgm-image

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!