Paul - 11 months ago 57

R Question

I have the following vector:

`vec<-as.vector(rnorm(1:924))`

And would like to reshape it into a matrix of the form 33 X 28. Then convert the matrix into a gray scale pixel like image.

In MATLAB, I know there exists

Also, can the mean and maximum be adjusted like in MATLAB for the gray scale intensity?

Answer Source

You are looking for `?heatmap`

:

```
heatmap(matrix(vec,33,28),Rowv=NA,Colv=NA,col=paste("gray",1:99,sep=""))
```

You can adjust the min/max color via the `col`

argument. Look at `?image`

, `?heat.colors`

and friends.