1

I have a very simple data-set that is organized as a grid/raster/table:

1,2,3
4,5,6
7,8,9

I'd like to read it in tidyR (and cognates) into:

x,y,value
1,1,1
1,2,2
1,3,3
.....

It seems like a straightforward problem but I can't figure out how to attack it.

Ronak Shah
  • 377,200
  • 20
  • 156
  • 213
CarrKnight
  • 2,768
  • 2
  • 23
  • 25

1 Answers1

1

Here is one approach:

library(raster)
r <- raster(matrix(1:9, nrow=3, byrow=T))
cbind(rowColFromCell(r, 1:ncell(r)), values(r))
Nimantha
  • 6,405
  • 6
  • 28
  • 69
Robert Hijmans
  • 40,301
  • 4
  • 55
  • 63