world 516 - applyworld 516 functionx xworld$exact_extractcrop_areaworldsumError in applyworld 516 functionx xworld$exact_extractcrop_areaworldsum argument FUN is missing with no default
The error message suggests that the "FUN" argument is missing in the apply function. The "FUN" argument specifies the function to be applied to each column or row of the data.
To fix the error, you need to specify a function for the "FUN" argument. For example, if you want to divide each element in the selected columns by the sum of the crop area, you can use the following code:
world[, 5:16] <- apply(world[, 5:16], 2, function(x) x / sum(world$exact_extract.crop_area..world...sum..))
In this code, the 2 in the apply function specifies that the function should be applied to each column (you can use 1 for applying the function to each row). The function function(x) x / sum(world$exact_extract.crop_area..world...sum..) divides each element in the selected columns by the sum of the crop area.
Make sure to adjust the column numbers and the variable name according to your data.
原文地址: https://www.cveoy.top/t/topic/jbUH 著作权归作者所有。请勿转载和采集!