簡體   English   中英

r 編程-邏輯回歸 plot

[英]r programming - logistic regression plot

  mutate(prob = ifelse(outcome == "pos", 0","1"))%>%
>   ggplot(aes( plasma_glucose, prob)) +
+   geom_point(alpha = 1) +
+   geom_smooth(method = "glm", method.args = list(family = "binomial")) +
+   labs(
+     title = "Logistic Regression Model", 
+     x = "Plasma Glucose Concentration",
+     y = "Probability of being diabete-pos"
+   )

輸出錯誤: mutate() column prob有問題。 prob = ifelse(outcome == "pos", 0, 1, ) x 未使用的參數 (alist())

我是 R 編程的新手,不知道如何糾正上面的代碼? 我正在嘗試 plot 邏輯回歸結果。

這是關於您的第一個錯誤消息unused argument (alist())的答案,以防其他人通過谷歌搜索該錯誤消息到達這里:

  • 如果您嘗試使用此 function 沒有的參數調用 function,則會在 R 中出現unused argument錯誤:例如:
foo <- function(x) x

foo(x = 10, y = 10) # notice the y-argument
#> Error in foo(x = 10, y = 10): unused argument (y = 10)
  • 如果調用帶有尾隨逗號的 function,則會出現unused argument (alist())錯誤,因為 R 將其視為另一個完全空的參數。 例如:
foo(x = 10, ) # notice the comma
#> Error in foo(x = 10, ): unused argument (alist())

正如@Rfanatic 在評論中所說,刪除多余的逗號,此錯誤消息就會消失。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM