2017-06-27 53 views
0

我試圖用compare_means()進行方差分析。使用樣本數據集ToothGrowth作爲一個例子,我要實現的是這樣的:compare_means():「必須解析爲整數列位置,而不是符號」在公式中使用字符串/符號時

#directly calling column name 
compare_means(len~supp, data=ToothGrowth, group.by = "dose", method = "anova") 

,除了我的公式中supp是一個字符串。

直接將字符串作爲參數傳遞會導致模型公式中出現錯誤。所以,我想轉換的字符串名稱或符號:

#convert string column name to name/symbol 
x <- as.name("supp") #as.symbol("supp") 
compare_means(len~x, data=ToothGrowth, group.by = "dose", method = "anova") 

但都返回了同樣的錯誤:

Error: x must resolve to integer column positions, not a symbol

我已經檢查了類似的錯誤消息像Error All select() inputs must resolve to integer column positions. The following do not:,但他們都不來解決我的問題。

請指示我該做什麼。任何幫助將非常感激!

回答

相關問題