Smart猫小萌
您可以使用此“无错误”功能重新定义:sample = function(x, size, replace = F, prob = NULL) { if (length(x) == 1) return(x) base::sample(x, size = size, replace = replace, prob = prob)}测试一下:> sapply(1:7, base::sample, size = 1)[1] 1 2 2 4 4 4 4> sapply(1:7, sample)[1] 1 2 3 4 5 6 7