私は棒グラフをプロットする関数を書いています。しかし、私がファセットラップになると、「〜」記号が物事を困難にしています。関数内にfacet_wrap(ggplot2)を書く方法
rf.funct <- function(dat, predictor, feature){
ggplot(get(dat), aes(get(predictor), N)) +
geom_bar(stat = 'identity') +
facet_wrap(get(~feature)) # this is where the problem is
}
私は次のことを試してみた:
facet_wrap((get(~feature))) # invalid first argument
facet_wrap(paste0("~ ", get(feature))) # object 'feature' not found
は、どのように私は必ず「〜」記号が関数に含まれます作るのですか?
機能は文字列か? – JasonWang
コードから 'get'を削除するとどうなりますか? –
'facet_wrap(paste("〜 "、feature))'。そして、@ JakeKauppが言ったように、 'get'のすべてのインスタンスを取り除きます。 – eipi10