I am trying to perform a "t-test" for 4 population rasters for the entire tropical strip for my graduate thesis. Sample years are 2000-2005-2010-2015. I am using this script:
setwd("C:/Users/MICITT/Desktop/TESIS_MSC_MARCOMM/Poblacion")
require(raster)
require(rgdal)
pob00 <- raster("PRUEBA_rem_pob00_SC.tif")
pob05 <- raster("PRUEBA_rem_pob05_SC.tif")
pob10 <- raster("PRUEBA_rem_pob10_SC.tif")
pob15 <- raster("PRUEBA_rem_pob15_SC.tif")
pob_ttest <- t.test(pob00, pob05, pob10, pob15, alternative = "two.sided", mu = 0, paired = FALSE, var.equal = FALSE,
conf.level = 0.95)
writeRaster(pob_ttest, filename = "C:/Users/MICITT/Desktop/TESIS_MSC_MARCOMM/Poblacion/ttestprueba", format="GTiff", overwrite=TRUE"
However, when I try to save the raster, it displays the following error:
Error in (function (classes, fdef, mtable) :
unable to find an inherited method for function ‘writeRaster’ for signature ‘"htest", "character"’
I need to get a final raster that gives me the value of "t", "df" and "p-value" per pixel. Anyone know how to solve this?
pob00[], pob05[], ...
This will return the values of the tasters. I imagine that output of the 't.test' is not a raster, which is the problem in calling 'writeRaster'. It pays to look at your objects.