Hi All
i am trying to do a correlation matrix forbur first subset the variables to numeric variables only. I did that with this code
d4<-which(sapply(d3, is.numeric))
is.numeric(d4)
How ever when i am trying to create a new data for the correlation, i get this error
i have checked all my syntax and don't seem to know where i am going wrong
Please help!
d5<d4[,c('SW','MOI','YOI','DOI_CMC','RMOB','RYOB','RDOB_CMC','RCA','Region','TPR','DPR','NV','HEL','Has_Radio','Has_TV','Religion','WI','MOFB','YOB','DOB_CMC','DOFB_CMC','AOR','MTFBI','DSOUOM_CMC','RW','RH','RBMI')]
cor(d5)
library(Hmisc)
rcorr(as.matrix(d4))
ERROR MESSAGE
d5<-d4[,c('SW','MOI','YOI','DOI_CMC','RMOB','RYOB','RDOB_CMC','RCA','Region','TPR','DPR','NV','HEL','Has_Radio','Has_TV','Religion','WI','MOFB','YOB','DOB_CMC','DOFB_CMC','AOR','MTFBI','DSOUOM_CMC','RW','RH','RBMI')]
Error in d4[, c("SW", "MOI", "YOI", "DOI_CMC", "RMOB", "RYOB", "RDOB_CMC", :
incorrect number of dimensions
cor(d5)
SBP WT CSBP CWT
SBP 1.0000000 0.3768497 0.7119719 0.3260822
WT 0.3768497 1.0000000 0.2667614 0.8312830
CSBP 0.7119719 0.2667614 1.0000000 0.1988989