[R] Need frequency distribution for x,y coordinates
Jim Lemon
bitwrit at ozemail.com.au
Sun Feb 12 04:12:10 CET 2006
mark shanks wrote:
>
> Hi,
>
> I have a set of data in x,y coordinates across the range of -5 to 5
in each
> dimension. I would like to obtain the frequency distribution of the
> different points, and then graph them so you can see which of the
points are
> the most frequently occurring.
>
> This would seem to be easy in Matlab, which has the hist3 command for
doing
> frequency distributions/histograms in 3 dimensions. However, as far
as I can
> tell, R does not have a hist3 command.
If a 2D display is okay, you can use the color2D.matplot function in the
plotrix package to plot the output of something like kde2d in MASS:
x<-seq(-5,5,by=0.1)
xdens<-kde2d(sample(x,500,TRUE),sample(x,500,TRUE),n=11)
color2D.matplot(xdens$z,c(1,0),c(0,1),c(0,0),
show.legend=TRUE,xlab="Columns",ylab="Rows")
Jim
More information about the R-help
mailing list