data(plants_df, plants_distance, plants_response)
# Test for spatial autocorrelation in response variable
moran_test <- moran(
x = plants_df[[plants_response]],
distance.matrix = plants_distance,
distance.threshold = 1000
)
# View test results
moran_test$test
# Access components
moran_test$test$moran.i # Observed Moran's I
moran_test$test$p.value # P-value
moran_test$test$interpretation # Text interpretation
Run the code above in your browser using DataLab