"undefined columns selected"

Hi everyone,
I have seen that other people have already had this type of problem but I do not understand how to solve it.

I am learning how to do hierarchical classifications but every time I put


I have this error message :

Error in `[.data.frame`(smp, , var) : undefined columns selected

Here is my entire little script :

smp <- read.csv2("smp2.csv",header=T)
var <- c("age","n.enfant","scz.cons","dep.cons","grave.cons","rs","ed","dr")
cah <- hclust(dist(t(scale(smp[,var]))),method="ward.D")    
#It does not work from here
plot(cah,xlab="",ylab="",main="Classification hiérarchique")
obj <- cor(smp[,var],use="pairwise.complete.obs")

And here is a dropbox link to my data if you need : Dropbox - smp2.csv - Simplify your life

Thank you in advance, have a great week-end !

var contains the name grave.cons but the column in smp is named grav.cons. Try

var <- c("age","n.enfant","scz.cons","dep.cons","grav.cons","rs","ed","dr")

Wow, I am totally amazed at how much I can bump into a problem when the solution is so simple.
A big thank you

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.