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.
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