我已經將柵格文件導入到R中 - 它是分類的,有兩個值0和1. 我需要將它作爲因子存儲。將柵格數據轉換爲R中的因子
我曾嘗試以下:
#as.factor when importing
mydata.factor <- as.factor(raster("mydata.tif"))
#or import first then try converting
mydata <- raster(mydata.tif)
mydata.factor <- as.factor(mydata)
#or call just values
mydata <- raster(mydata.tif)
mydata$values <- as.factor(mydata$values)
#or based on the example in the Raster package, something like this
mydata <- raster(mydata.tif)
mydata.factor <- as.factor(mydata)
mydata.factorlevels <- levels(mydata.factors)[[1]]
我不能完全得到我想要的東西,這是一個層,當所謂的到另一個功能(在包spdedp的joincount.multi功能)是公認的一個因素。任何提示將非常感謝!