Create an STGrid from a data.frame

stgrid_from_data_frame(this_df = NULL, mapping = NULL, bin_size = 25)

Arguments

this_df

A data.frame

mapping

Please provide a named vector indicating which column map to "x", "y", and "feature" in the STGrid object.

bin_size

The size of the bin.

Value

An STGrid object.

Examples

d <- data.frame(foo=runif(1000, 0, 1000), bar=runif(1000, 0, 1000), bla=sample(letters, 1000, replace=TRUE))
st <- stgrid_from_data_frame(d, mapping=c("x"="foo", "y"="bar", "feature"="bla"))
#> 
  |                                                        
  |                                                  |   0%
  |                                                        
  |==                                                |   4%
  |                                                        
  |====                                              |   8%
  |                                                        
  |======                                            |  12%
  |                                                        
  |========                                          |  15%
  |                                                        
  |==========                                        |  19%
  |                                                        
  |============                                      |  23%
  |                                                        
  |=============                                     |  27%
  |                                                        
  |===============                                   |  31%
  |                                                        
  |=================                                 |  35%
  |                                                        
  |===================                               |  38%
  |                                                        
  |=====================                             |  42%
  |                                                        
  |=======================                           |  46%
  |                                                        
  |=========================                         |  50%
  |                                                        
  |===========================                       |  54%
  |                                                        
  |=============================                     |  58%
  |                                                        
  |===============================                   |  62%
  |                                                        
  |=================================                 |  65%
  |                                                        
  |===================================               |  69%
  |                                                        
  |=====================================             |  73%
  |                                                        
  |======================================            |  77%
  |                                                        
  |========================================          |  81%
  |                                                        
  |==========================================        |  85%
  |                                                        
  |============================================      |  88%
  |                                                        
  |==============================================    |  92%
  |                                                        
  |================================================  |  96%
  |                                                        
  |==================================================| 100%
#> 
st