bpoconnor / DFA.CANCOR

An R package for discriminant function analysis & canonical correlation analysis
0 stars 0 forks source link

Error in order(y): unimplemented type 'list' in 'orderVector1' with function DFA of DFA.CANCOR #1

Open jeremiah75 opened 2 years ago

jeremiah75 commented 2 years ago

This is the code:

y <- c(1, 1, 1, 1, 1, 2, 2, 2, 2, 2)
x1 <- c(4, 3, 3, 2, 2, 8, 7, 5, 3, 3)
x2 <- c(2, 1, 2, 2, 5, 3, 4, 5, 4, 2)
discrim <- data.frame(y, x1, x2)
discrim$y <- as.factor(discrim$y)
head(discrim,3)

When I execute this code:

library(DFA.CANCOR)
DFA(data = discrim, 
    groups = 'y', 
    variables = c('x1','x2'),
    predictive = TRUE,
    priorprob = 'SIZES', # default is 'EQUAL'
    verbose = TRUE)

The following text appears:

Error in order(y): unimplemented type 'list' in 'orderVector1' Traceback:

1. DFA(data = discrim, groups = "y", variables = c("x1", "x2"), . predictive = TRUE, priorprob = "SIZES", verbose = TRUE)

2. squareTable(var1 = donnes[, 1], var2 = classes$dfa_class, grpnames, . tabdimnames = c("Original", "Predicted"))

3. factor(var2, labels = grpnames)

4. order(y)

I have proved with unlist() the data frame like in Weird behaviour by ordering a data frame, but it does not work. I imported from a .csv instead of code by hand too, but does not work neither. I have seen that y as a factor neither is the problem.

This is the example cited in the package documentation:

# data from Tabachnik & Fiddel (2019, p 307)
table9.1 <- '
1 87 5 31 6.4
1 97 7 36 8.3
1 112 9 42 7.2
2 102 16 45 7.0
2 85 10 38 7.6
2 76 9 32 6.2
3 120 12 30 8.4
3 85 8 28 6.3
3 99 9 27 8.2'
table9.1 <- data.frame(read.table(text=table9.1, col.names=c('group','perf','info','verbexp','age')))
DFA(data = table9.1,
groups = 'group',
variables = c('perf','info','verbexp','age'),
predictive = TRUE, priorprob = 'SIZES', covmat_type='within',verbose = TRUE)

.. and works nice ... my code, apparently, is very similar. Please, help!

Thank you very much in advance!

jeremiah75 commented 2 years ago

This is the code:

y <- c(1, 1, 1, 1, 1, 2, 2, 2, 2, 2)
x1 <- c(4, 3, 3, 2, 2, 8, 7, 5, 3, 3)
x2 <- c(2, 1, 2, 2, 5, 3, 4, 5, 4, 2)
discrim <- data.frame(y, x1, x2)
discrim$y <- as.factor(discrim$y)
head(discrim,3)

When I execute this code:

library(DFA.CANCOR)
DFA(data = discrim, 
    groups = 'y', 
    variables = c('x1','x2'),
    predictive = TRUE,
    priorprob = 'SIZES', # default is 'EQUAL'
    verbose = TRUE)

The following text appears:

Error in order(y): unimplemented type 'list' in 'orderVector1' Traceback:

1. DFA(data = discrim, groups = "y", variables = c("x1", "x2"), . predictive = TRUE, priorprob = "SIZES", verbose = TRUE)

_2. squareTable(var1 = donnes[, 1], var2 = classes$dfaclass, grpnames, . tabdimnames = c("Original", "Predicted"))

3. factor(var2, labels = grpnames)

4. order(y)

I have proved with unlist() the data frame like in Weird behaviour by ordering a data frame, but it does not work. I imported from a .csv instead of code by hand too, but does not work neither. I have seen that y as a factor neither is the problem.

This is the example cited in the package documentation:

# data from Tabachnik & Fiddel (2019, p 307)
table9.1 <- '
1 87 5 31 6.4
1 97 7 36 8.3
1 112 9 42 7.2
2 102 16 45 7.0
2 85 10 38 7.6
2 76 9 32 6.2
3 120 12 30 8.4
3 85 8 28 6.3
3 99 9 27 8.2'
table9.1 <- data.frame(read.table(text=table9.1, col.names=c('group','perf','info','verbexp','age')))
DFA(data = table9.1,
groups = 'group',
variables = c('perf','info','verbexp','age'),
predictive = TRUE, priorprob = 'SIZES', covmat_type='within',verbose = TRUE)

.. and works nice ... my code, apparently, is very similar. Please, help!

Thank you very much in advance!

I add this conversation in stackoverflow: https://stackoverflow.com/questions/71641463/r-problem-error-in-ordery-unimplemented-type-list-in-ordervector1-with-f