由于我需要在函数中使用ggplot2,因此需要非标准评估模式 . 因此,使用 aes_string"price" . 但是,不再定义 ..count..

ggplot(diamonds, aes_string(x="price", ..count../sum(..count..))) + geom_histogram(binwidth = 500)