Hello, 

I am running cluster analysis, and am attempting to create a graph of my clusters.  I keep on getting an error that says that my figure margins are too large.

 d <- file.choose()
 d <- read.csv(d,header=TRUE)
 
 mydataS <- scale(d, center = TRUE, scale=TRUE)
 
 #Converts mydataS from a matrix to a data frame
 mydataS2 <- as.data.frame(mydataS)
 
#removes "coden" variable 
myvars <- names(mydataS2) %in% c("coden") 
 mydataSNc <- mydataS2[!myvars]
 
#Determine number of clusters
wss <- (nrow(mydataSNc)-1)*sum(apply(mydataSNc,2,var))
 for (i in 2:15) 
   wss[i] <- sum(kmeans(mydataSNc, centers=i)$withinss)
 
plot(1:15, wss, type="b", xlab="Number of Clusters",ylab="Within groups sum of squares")
 
#perform Kmeans with 2 clusters
 kmSNc2 <- kmeans(mydataSNc,2)
 #print conponents of kmSNc2
 print(kmSNc2)

 #plot 2 clusters
 plot(mydataSNc, col = kmSNc2$cluster)
 #plot 2 centers
 points(kmSNc2$centers,col = 1:2, pch = 8)

After the above bolded code, I get this following error:

>  #plot 2 clusters
>  plot(mydataSNc, col = kmSNc2$cluster)
Error in plot.new() : figure margins too large
>  #plot 2 centers
>  points(kmSNc2$centers,col = 1:2, pch = 8)
Error in plot.xy(xy.coords(x, y), type = type, ...) : 
  invalid graphics state


I am have just started using R, so I am most definitely a beginner.  Any help that could be offered would be greatly appreciated. 

Thanks,

Karly Harrod
SULI Intern, Computational Research Division
kharrod@lbl.gov
Lawrence Berkeley National Laboratory


	[[alternative HTML version deleted]]

