On May 7, 2012, at 6:15 PM, stat curio wrote:

Hello,

I have a data frame which looks like

head(d)
 a1 a2        n  j     col
1  1  1 88341002 11 #E7E7E7
2  1  2 25094882 11 #E7E7E7
3  1  3 16916246 11 #E7E7E7
4  1  4 14289229 11 #E7E7E7
5  1  5 11945929 11 #E7E7E7
6  1  6  8401235 11 #E7E7E7

The values in 'j' run from 1 to 11. I would like to plot the point (a1,a2)
with color given by j

I tried

mi <- image(d[,"a1"],d[,"a2"],d[,"j"],col=mycols(length(f)),useRaster=TRUE)

(where mycols is from colorRampPalette(c("#000000","#FFFFFF"),bias=1.5)

However, i got the following error:

Error in image.default(d[, "a1"], d[, "a2"], d[, "j"], col =
mycols(length(f)),  :
 increasing 'x' and 'y' values expected


What am i doing wrong here? I have a million points and so would like to
write to a png or jpeg file.

It is difficult to tell. We do not have either dput(head(d)) or str(d) so some of the potential newbie R potholes remain over the horizon of our sight. The z-argument is supposed to be a matrix while x and y are supposed to be the locations of the grid, so perhaps you need to call image() like:

?image

image(x=unique(d[,"a1"]),
       y=unique(d[,"a2"]),
        z=matrix( d[,"j"], nrow=length( unique(d[,"a1"]) ),
                           ncol=length( unique(d[,"a2"]) )
                  ),
             ... <other-args>...
                     )

        [[alternative HTML version deleted]]

You can thank us by starting to post in plain text.

PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
... and
and provide commented, minimal, self-contained, reproducible code.

--
David Winsemius, MD
West Hartford, CT

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to