Hello, I have a large data set that has more columns than rows (sample data below). I am trying to perform a partitioning cluster analysis and then plot that using pca. I have tried using CLUSPLOT(), but that only allows for 'princomp' where I need 'prcomp' as I do not want to reduce my columns. Is there a way to edit the CLUSPLOT() code to use 'prcomp', please? # sample of my data PRVID,VAR1,VAR2,VAR3,VAR4,VAR5,VAR6,VAR7,VAR8,VAR9,VAR10,VAR11 PRV1,0,54463,53049,62847,75060,184925,0,0,0,0,0 PRV2,0,2100,76,131274,0,0,0,0,0,0,18 PRV3,967,0,0,0,0,0,0,0,0,3634,0 PRV4,817,18344,3274,9264,1862,0,0,141,0,0,0 PRV5,0,0,0,0,0,0,29044,0,0,0,0 PRV6,59,6924,825,3008,377,926,0,0,10156,0,5555 PRV7,11,24902,36040,47223,20086,0,0,749,415,0,0 library(cluster) fn = "big.csv"; tbl = read.table(fn, header=TRUE, sep=",", row.names=1); mat <- as.matrix(tbl); newtbl <- prop.table(mat,1)*100; num.clust <- 3; fitnw <- kmeans(newtbl, num.clust); clusplot(newtbl, fitnw$cluster, color=TRUE, shade=TRUE, lines=0, main= paste('Principal Components plot - Kmeans ', clust.level, ' Clusters') ) Error in princomp.default(x, scores = TRUE, cor = ncol(x) != 2) : 'princomp' can only be used with more units than variables Thank you for R and any assistance you may offer! Jo [[alternative HTML version deleted]]
Hello, I have a large data set that has more columns than rows (sample data below). I am trying to perform a partitioning cluster analysis and then plot that using pca. I have tried using CLUSPLOT(), but that only allows for 'princomp' where I need 'prcomp' as I do not want to reduce my columns. Is there a way to edit the CLUSPLOT() code to use 'prcomp', please? # sample of my data PRVID,VAR1,VAR2,VAR3,VAR4,VAR5,VAR6,VAR7,VAR8,VAR9,VAR10,VAR11 PRV1,0,54463,53049,62847,75060,184925,0,0,0,0,0 PRV2,0,2100,76,131274,0,0,0,0,0,0,18 PRV3,967,0,0,0,0,0,0,0,0,3634,0 PRV4,817,18344,3274,9264,1862,0,0,141,0,0,0 PRV5,0,0,0,0,0,0,29044,0,0,0,0 PRV6,59,6924,825,3008,377,926,0,0,10156,0,5555 PRV7,11,24902,36040,47223,20086,0,0,749,415,0,0 library(cluster) fn = "big.csv"; tbl = read.table(fn, header=TRUE, sep=",", row.names=1); mat <- as.matrix(tbl); newtbl <- prop.table(mat,1)*100; num.clust <- 3; fitnw <- kmeans(newtbl, num.clust); clusplot(newtbl, fitnw$cluster, color=TRUE, shade=TRUE, lines=0, main= paste('Principal Components plot - Kmeans ', clust.level, ' Clusters') ) Error in princomp.default(x, scores = TRUE, cor = ncol(x) != 2) : 'princomp' can only be used with more units than variables Thank you for R and any assistance you may offer! Jo [[alternative HTML version deleted]]