Re: [R] Formatting with strings

2014-04-23 Thread arun
ls=gsub("\\D+","",Lines1[indx]) res A.K. - Original Message - From: Nico Met To: R help Cc: Sent: Wednesday, April 23, 2014 3:28 PM Subject: [R] Formatting with strings Dear all, I have object where I stored clusters in the following manner: ---CLUSTER 1 --- 3 4 5 6 -

Re: [R] Formatting with strings

2014-04-23 Thread Nico Met
Many thanks Jim. It works for my large data set! Best Regards Nico On Wed, Apr 23, 2014 at 1:45 PM, jim holtman wrote: > try this: > > > x <- readLines(textConnection("---CLUSTER 1 --- > + 3 > + 4 > + 5 > + 6 > + ---CLUSTER 2 --- > + 9 > + 10 > + 8 > + 11")) > > > > # create a list of where t

Re: [R] Formatting with strings

2014-04-23 Thread jim holtman
try this: > x <- readLines(textConnection("---CLUSTER 1 --- + 3 + 4 + 5 + 6 + ---CLUSTER 2 --- + 9 + 10 + 8 + 11")) > > # create a list of where the 'clusters' are > clust <- c(grep("CLUSTER", x), length(x) + 1L) > > # get size of each cluster > clustSize <- diff(clust) - 1L > > # get cluster numb

[R] Formatting with strings

2014-04-23 Thread Nico Met
Dear all, I have object where I stored clusters in the following manner: ---CLUSTER 1 --- 3 4 5 6 ---CLUSTER 2 --- 9 10 8 11 Now want to format the data in the following way: Object Cluster 31 41 51 61 9 2 10 2 8