Description Usage Arguments Details Value See Also Examples
This function builds a formula from the dataframe from the data
slot in the specified rasclass object.
1 | buildFormula(object, varlist = NULL)
|
object |
A |
varlist |
An optional |
A formula is built automatically using all the columns in the dataframe from the data
slot of the specified object. The formula is stored in the call
slot of the rasclass-class
object. The dependent variable in the formula will be the name specified in the samplename
slot of the given input object.
If not all columns from the data
slot should be used for classifiaction, the list of variables to include can be specified using the optional argument varlist. The samplename is specified previously when adding data to the rasclass-class object with the corresponding functions and should not be included in the varlist
argument.
A rasclass-class
object with the newly built formula in the formula
slot.
rasclass-package
,
rasclass-class
,
rasclassRaster-class
,
readRasterFolder
,
setRasclassData
,
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | ## Not run:
# Load data from external folder
object <- readRasterFolder(path = "mypath", samplename = "mysample",
filenames = c('myvar1.asc', 'myvar2.asc'))
## End(Not run)
# For this example, create artificial data
mysample <- c(rep(rep(c(1,2), each = 25), 25), rep(rep(c(3,4), each = 25), 25))
mysample <- mysample + sample(c(0, NA), 2500, replace = TRUE, prob = c(1, 10))
myvar1 <- rep(1:50, each = 50) + rnorm(2500, 0, 5)
myvar2 <- rep(rep(1:50), 50) + rnorm(2500, 0, 5)
myvar3 <- sample(1:2500)
newdata <- data.frame(mysample, myvar1, myvar2, myvar3)
# Prepare a rasclass object using the dataframe and specifying raster properties
object <- new('rasclass')
object <- setRasclassData(newdata, ncols = 50, nrows = 50,
xllcorner = 0, yllcorner = 0, cellsize = 1, NAvalue = -9999,
samplename = 'mysample')
# Classify and show results using all columns
object <- classifyRasclass(object)
summary(object)
# Change formula to exclude one variable
object <- buildFormula(object, varlist = c('myvar1', 'myvar3'))
# Classify and show results
object <- classifyRasclass(object)
summary(object)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.