I am trying to build a logistic regression using the code below, but I encounter the error that I am unable to identify the cause of! I have compared the contents of my df to the example used in a recent gtsummary seminar (https://cran.r-project.org/web/packages/gtsummary/vignettes/tbl_regression.html) and I can't find the cause.
Error in glm(disease_present ~ disease_cat, sex, age, data = df, : 'weights' must be a numeric vector
Code
mod <- glm(disease_present ~ disease_cat, sex, age,
data = df, family = binomial)
Data
df <-
structure(
list(
disease_cat = structure(
c(
7L,
2L,
2L,
2L,
2L,
5L,
2L,
2L,
2L,
2L,
2L,
3L,
2L,
2L,
5L,
2L,
2L,
2L,
2L,
2L,
2L,
2L,
5L,
5L,
5L,
2L,
8L,
2L,
8L,
2L,
7L,
2L,
7L,
2L,
7L,
8L,
8L,
2L,
2L,
7L,
2L,
7L,
7L,
2L,
2L,
2L,
2L,
2L,
5L,
5L
),
.Label = c(
"breast",
"prostate",
"colorectal",
"lung",
"melanoma",
"bladder",
"pancreatic",
"endometrial"
),
class = "factor"
),
disease_present = c(
1,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
1,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
1,
1,
1,
0,
1,
0,
1,
0,
1,
0,
1,
0,
1,
1,
1,
0,
0,
1,
0,
1,
1,
0,
0,
0,
0,
0,
1,
1
),
sex = structure(
c(
2L,
2L,
1L,
2L,
1L,
2L,
1L,
2L,
1L,
1L,
2L,
1L,
1L,
1L,
2L,
2L,
1L,
2L,
2L,
1L,
2L,
2L,
1L,
1L,
2L,
2L,
2L,
1L,
1L,
1L,
1L,
1L,
1L,
1L,
2L,
2L,
1L,
1L,
2L,
1L,
2L,
1L,
1L,
2L,
1L,
1L,
2L,
2L,
1L,
1L
),
.Label = c("female", "male"),
class = "factor"
),
age = c(
18,
41,
40,
45,
48,
25,
50,
56,
45,
46,
45,
28,
40,
50,
25,
50,
40,
40,
40,
40,
50,
50,
29,
26,
8,
55,
60,
40,
35,
40,
22,
45,
10,
45,
14,
21,
45,
53,
55,
18,
45,
18,
35,
53,
45,
45,
54,
48,
30,
44
)
),
row.names = c(NA,-50L),
class = c("tbl_df",
"tbl", "data.frame")
)