I have a data.frame like this:
X1 X2 n
1 -80.3845 43.19402 4
2 -80.3845 43.19402 4
3 -80.3845 43.19402 4
4 -80.3845 43.19402 4
You'll notice the values are all the same in each variable. What I'm trying to do is to create a new dataframe that is adjusted so that the variables X1 and X2 do not overlap. I need them to have a difference of 0.1. The final dataframe should look like this:
X1 X2 n
1 -80.3845 43.19402 4
2 -80.3845 43.29402 4
3 -80.2845 43.29402 4
4 -80.2845 43.19402 4
This graphic might help to represent what's happening:
The values represent longitudes and latitudes and I have kept the first dot in place and then gone upwards one place, then to the right one spot, then down one spot to number 4.
This is pretty easy for a few rows to do manually, but when we add more dots it gets more complicated. For any 'n' the first row is going to remain with the same values and the rows will snake around in a clockwise fashion. Therefore, for 8 rows it would look like this:
X1 X2 n
1 -80.3845 43.19402 8
2 -80.3845 43.29402 8
3 -80.2845 43.29402 8
4 -80.2845 43.19402 8
5 -80.2845 43.09402 8
6 -80.3845 43.09402 8
7 -80.4845 43.09402 8
8 -80.4845 43.19402 8
The highest number of 'n' I will have is about 400. My thought process is that I should try and calculate in advance what positions each number from 1-400 would be in in such a configuration as the images above. i.e. are they ... -3,-2,-1,0,1,2,3,... rows/columns away from the center point. Then use this to calculate the adjusted values in X1 (which can be thought of as the coordinate for columns) and X2 (which can be thought of as the coordinate for rows) accordingly.
Can anyone think of a better way of doing this?