我已經創建了下面的函數等內ggplot冠軍,關於
create_plot <- function(variable) {
return(qplot(data = white_wine, x = variable ,color =I('black'),fill =
qual_factor))+
ggtitle('Distribution of quality with respect to _______')}
下面我打電話有兩個不同的變量的函數:
create_plot(white_wine$total.sulfur.dioxide)
create_plot(white_wine$density)
我在ggtitle語法把「_______」 ,因爲我想要我調用的任何變量的名稱。
例如,
'enter code hereDistribution of quality with respect to total.sulfur.dioxide' when
white_wine$total.sulfur.dioxide is called, and ,'Distribution of quality with respect to density' when white_wine$density is called.
爲什麼不給函數添加第二個參數來定義放在標題中的名稱?然後使用'粘貼' – bouncyball