I have a data frame called df with 2 variables and 71 observations. The variables are dead and duration. Now I want to do a regression with lm(formula = dead ~ ., data = df)
. The dependend variable is dead, but I get this error
Error in model.frame.default(formula = dead ~ ., data = df, drop.unused.levels = TRUE) : object is not a matrix
I have tried to convert the data frame to a matrix and then do the lm()
, but then i get this error
Error in model.frame.default(formula = dead ~ ., data = df2, drop.unused.levels = TRUE) : 'data' must be a data.frame, not a matrix or an array
dput(df)
structure(list(DEAD = c(26L, 229L, 43L, 21L, 19L, 2L, 4L, 10L,
7L, 2L, 4L, 0L, 0L, 0L, 32L, 1L, 0L, 0L, 2L, 2L, 2L, 64L, 25L,
7L, 6L, 0L, 98L, 95L, 275L, 2L, 3L, 2L, 0L, 340L, 0L, 200L, 15L,
0L, 3L, 12L, 3L, 283L, 12L, 0L, 147L, 0L, 4L, 11L, 26L, 30L,
0L, 34L, 0L, 557L, 12L, 0L, 0L, 99L, 1L, 78L, 18L, 49L, 3L, 3L,
31L, 0L, 54L, 7L, 24L, 0L, 0L), DAYS = c(5, 19, 2, 15, 3, 13,
2, 5, 8, 4, 6, 2, 2, 2, 16, 2, 9, 2, 2, 2, 2, 12, 3, 20, 2, 2,
9, 5, 13, 2, 2, 2, 4, 13, 4, 45, 28, 2, 2, 2, 2, 4, 2, 3, 5,
10, 7, 2, 4, 6, 4, 9, 4, 33, 2, 3, 2, 3, 4, 19, 6, 3, 3, 3, 2,
5, 9, 4, 4, 3, 2)), .Names = c("DEAD", "DAYS"), row.names = 0:70, class = "data.frame")