The World’s Largest Online Community for Developers

'; r - Error in summary.formula : matrix variables must have column dimnames - LavOzs.Com

I am new to R, and I can't fix the bug after searching for one hour. It seems that there's no similar problem posted before.

I followed the instruction from ,and want to test the proportional assumption for my data.

Following is my code:

sf <- function(y) {
  c('Y>=1' = qlogis(mean(y >= 1)),
    'Y>=2' = qlogis(mean(y >= 2)),
    'Y>=3' = qlogis(mean(y >= 3)),
    'Y>=3' = qlogis(mean(y >= 4)),
    'Y>=3' = qlogis(mean(y >= 5)))

(s <- with(dat, summary(as.numeric(implied_rating) ~ GDP + importance, fun = sf)))

But the error occurs.

"Error in summary.formula(matrix(as.numeric(implied_rating)) ~ matrix(GDP) + : matrix variables must have column dimnames"

What should I do?

Many thanks in advance!

Solved. I thought dimnames is colnames... Just mannually set dimnames to every column. But I still wonder if there's better way to solve the problem.

R apply error: 'X' must have named dimnames
How to use the R 'with' operator in rpy2
fun= argument of summary function in R
R Code error in matrix: 'dimnames' must be a list
R: Convert dimnames into column in matrix