简体   繁体   中英

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"
+   )

output- Error: Problem with mutate() column prob . i prob = ifelse(outcome == "pos", 0, 1, ) . x unused argument (alist())

I am new to R programming and not sure how to rectify the above code? I am trying to plot logistic regression result.

Here is an answer regarding your first error message unused argument (alist()) , in case anybody else gets here by googling that error message:

  • You get the unused argument error in R if you try to call a function with an argument this function doesn't have: such as:
foo <- function(x) x

foo(x = 10, y = 10) # notice the y-argument
#> Error in foo(x = 10, y = 10): unused argument (y = 10)
  • You get the unused argument (alist()) error if you call a function with a trailing comma, as R see this as another - completely empty - argument. For example:
foo(x = 10, ) # notice the comma
#> Error in foo(x = 10, ): unused argument (alist())

As @Rfanatic said in the comments, remove the extra comma and this error message goes away.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM