Skip to main content
adding better explanation
Source Link
keithing
  • 301
  • 1
  • 3

Try replacing

x <- as.matrix(subset(d, select=Cs(rx, sex, age, obstruct, perfor, adhere, surg)))

with

x <- model.matrix( ~ rx + sex + age + obstruct + perfor + adhere + surg - 1, d)

The latter will convert the convert the factor rx to numeric dummy variables in the matrix x.

Try replacing

x <- as.matrix(subset(d, select=Cs(rx, sex, age, obstruct, perfor, adhere, surg)))

with

x <- model.matrix( ~ rx + sex + age + obstruct + perfor + adhere + surg - 1, d)

Try replacing

x <- as.matrix(subset(d, select=Cs(rx, sex, age, obstruct, perfor, adhere, surg)))

with

x <- model.matrix( ~ rx + sex + age + obstruct + perfor + adhere + surg - 1, d)

The latter will convert the convert the factor rx to numeric dummy variables in the matrix x.

Source Link
keithing
  • 301
  • 1
  • 3

Try replacing

x <- as.matrix(subset(d, select=Cs(rx, sex, age, obstruct, perfor, adhere, surg)))

with

x <- model.matrix( ~ rx + sex + age + obstruct + perfor + adhere + surg - 1, d)