Getis-Ord Gi* for Coordinate data

Hi All,

I want to produce a Getis-Ord Gi* hotspot analysis using some data I gathered that tracked a person in a space. What I have is a "room" of known size and location (rectangle in shape) and a series of coordinates which is the tracking data (X and Y). I have so far managed to plot these coordinates inside a box and have done a density plot to generate a heatmap (of sorts). Now what I want to do is divide the "room" up into 2cm squares and perform a Getis-Ord Gi* calculation.

I am trying to create a Getis-Ord Gi* plot/ statistic for my data. My data has 6 columns, column 2 (HPY) and column 3 (HPX) are the X and Y coordinates (or Y and X as it is layed out).

I have made some progress, but I fear my coordinate data needs to be converted to a different data type for the package to work? I am no expert in R or spatial statistics. You will be able to see what I have done in the markdown file. As I am learning I am leaving notes to myself as a sort of running comentry.

R Markdown File:!AptelOm1uCFblhDAYTYmp4Op-NLk?e=ldIb7B


Any help would be much appreciated.