R generate 2D histogram from raw data

后端 未结 6 1943
谎友^
谎友^ 2021-02-01 07:47

I have some raw data in 2D, x, y as given below. I want to generate a 2D histogram from the data. Typically, dividing the x,y values into bins of size 0.5, and count the number

6条回答
  •  长发绾君心
    2021-02-01 08:12

    freq <-  as.data.frame(table(findInterval(xy[,1], x.bin),findInterval(xy[,2], y.bin)))
        freq[,1] <- as.numeric(freq[,1])
        freq[,2] <- as.numeric(freq[,2])
    

    This is probably wrong since it destroys the original indices.

提交回复
热议问题