0

I'm rather new to programming and the site so let me know if I screw up on this explanation.

I have a rather long series of x, y coordinates representing a character in 2d space. Let's say that space is 200 x 400. I want to represent the amount of time the character is in each x, y coordinate by means of a pretty chloropleth.

I want to use heatmaply for this because I think the output is pretty and I want my audience to be able to zoom in on the data. It isn't really meant to do density estimation (I think?) so I'm trying to work around it.

I suppose the way to do this is to fill a 200x400 dataframe with counts of the number of occurrences of each x, y coordinate in the data at each x, y coordinate in the frame. Essentially, to build a 2d map out of the data frame and impose the counts upon it

So, I suppose my questions are:

1). How do I get the count of each unique x, y coordinate in my set

2). How might I pass those counts easily to the matching x, y cell in my 200x400 dataframe full of zeroes?

This seems like it should be easy but I can't seem to figure it out! I'm a novice to r and can't see the shape of what I need to do.

Sfawas
  • 3
  • 1
  • 1
    Please post a sample data to help us better understand the dimension and characteristics of your data. – Hasan Bhagat Sep 14 '20 at 03:41
  • Just a simple dataframe where range of x is 0-200 and range of y is 0-400, representing the character being in location x, y https://pastebin.com/BL3NSf2i – Sfawas Sep 14 '20 at 04:46

1 Answers1

0

You can use the table function to get your matrix of counts.

table(X,Y)

X and Y should be columns of coordinates.

Output based on some sample data enter image description here

Dharman
  • 30,962
  • 25
  • 85
  • 135
Hasan Bhagat
  • 395
  • 1
  • 8