Re: [R] Partition data into clusters

From: Suhaila Zainudin <suhaila.zainudin_at_gmail.com>
Date: Mon, 24 Mar 2008 22:43:42 -0700

Hi,

Just to inform you that I found the solution for the write.csv task I mentioned earlier. Searching thru the r-help leads me to this solution..

###Your soln starts
xx <- max(cl2$cl.kmr10.cluster)
# find out how many clusters there are.
my.clusters <- list(NULL) # set up an empty list for storage

# Loop through the dataset and subset by cluster.
for(i in 1:xx) {
 my.clusters[[i]] <- subset(cl2,
cl2$cl.kmr10.cluster==i)
 }
# Eh voilą!

my.clusters

### Your solution ends

# Soln for writing the clustered results into multiple files using loop.

for(i in 1:xx) {
  write.csv(my.clusters[[i]], paste("mycluster",i,sep=".")) }

Regards

suhaila

        [[alternative HTML version deleted]]



R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Tue 25 Mar 2008 - 05:49:20 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Tue 25 Mar 2008 - 07:30:24 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive